Bill Allombert on Sat, 26 Nov 2016 22:14:07 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Unexpected eval of loop index in gp64-2.9.1


On Sat, Nov 26, 2016 at 07:22:29PM +0000, Jacques Gélinas wrote:
> ckex(ex="0==1-1") = print(ex" --> "eval(ex));
> 
> for(k=0, 0, j=k; ckex("j==0"); ckex("k==0"))
> 
> j==0 --> 1
> 
> k==0 --> 0
> 
> Maybe I missed something in the documentation ?

k is a loop index. In GP, loop indices are local variables statically
scopped to the loop.  As a result, k is not visible by the function
ckex().  The string "k==0" is evaluated in the context of the function
ckex(), and k is not defined there, so the result is 0 (false).  

On the other hand, j is a global variable, so is visible by ckex().

Cheers,
Bill.

P.S.: Could you confirm 2.9.1-pre1 fix the problem with writebin on Windows ?