Page 2 of 2

Re: Function called, doesn't answer!

Posted: Sat Jun 25, 2016 7:32 am
by Ormente
Nice catch Ross... maybe next time you'll realy outsmart the debugger. Keep trying! :wink:

Re: Function called, doesn't answer!

Posted: Sun Jun 26, 2016 1:04 am
by RossG
This is the test stack I did to help me find that bug.

Doesn't do the important bit. Just updates the numbers
generated by the "HowMany30" and "WayBack" functions.

Click the "Go" button then "Add a Number" and if you
are quick you'll see (some) numbers changing.

Re: Function called, doesn't answer!

Posted: Sun Jun 26, 2016 10:02 am
by Ormente
Thanks. I had a look.

I tested the culprit loop repeat with x = -1 to -30, and as expected it didn't work.

In fact, repeat with x = A to B have two ways of "not working".
- It could hang for a while if LC did naively increment A until it reach B (=)
- It could return immediatly if LC check that A >= B beforehand

Looks like it's the second one. I learned something. Nice!

Re: Function called, doesn't answer!

Posted: Mon Jun 27, 2016 11:14 am
by [-hh]
[Repost. I try to do a better wording.]

Hi Ormente.
In the sense of your explanation:

repeat with x=A to B (meant as x=A up to B)
is, as RossG said, by LC interpreted as
repeat with x=A to B step 1
no matter the values of A and B

repeat with x= A down to B
is by LC interpreted as
repeat with x=A to B step -1
no matter the values of A and B

If we now set our own step-value, this setting gets precendence.
That's why
repeat with i=-1 to -30 step -1
works (counts from -1 down to -30)

[and similarly
repeat with i=1 down to 30 step 1
works (counts from 1 up to 30)]

Hermann