parsec icon indicating copy to clipboard operation
parsec copied to clipboard

JDF does not accept negative STEP size.

Open v0dro opened this issue 2 years ago • 2 comments

Describe the bug

In the variables of a JDF task, if I have the following

level = max_level .. min_level .. -1

I expect the level parameter to go from max_level to min_level with a step of -1. However, the .c generated for this task shows the step as 1, leading to a malfunction.

Expected behavior

The level should decrease by 1.

Environment (please complete the following information):

Parsec master branch.

v0dro avatar Mar 15 '23 01:03 v0dro


level = h2_params->max_level .. h2_params->min_level .. -1
block = 0 .. %{ return pow(2, level)-1; %}

v0dro avatar Mar 22 '23 23:03 v0dro

We discussed this today, and it's complicated, because we want to support an empty range too.

If we use arbitrary functions a(), b(), and i() and write

x  = %{ return a(); %} .. %{ return b(); %} .. %{ return i(); %}

and want to support i() returning positive or negative values, and at the same time support empty ranges, we fall into an impossible case: a() could return 1, b() return 0, and i() return 1 the first call, and -2 the second time, and x would take the values [1, 2, 0] (in that order). But if I have a() return 1, b() return 0 and i() return only positive values, this is supposed to define an empty range.

Negative increments can always be rewritten:

x = 0 .. -10 .. -1

can be rewritten

x = -10 .. 0 .. 1

After discussing this at length today, we have decided that the .. range will always go from min to max, growing.

As a convenience for users, we'll introduce a negative range (notation to be decided), that will always go from max to min, decreasing.

therault avatar Mar 31 '23 15:03 therault