Bill Allombert on Thu, 16 Apr 2015 14:42:13 +0200


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

Re: my() in global context


On Mon, Mar 23, 2015 at 08:15:00AM +0100, Joerg Arndt wrote:
> Is the following intended behavior?
> 
> ? my(i=77);
> ? i
> i
> 
> This is outside any braces.

Yes, in GP, the outer scope is the logical line.

So you can do e.g.

? my(s=0);for(i=1,100,s+=i);s
%1 = 5050

without changing the state of GP.

Cheers,
Bill.