Ilya Zakharevich on Wed, 8 Nov 2000 15:58:26 -0500 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: grammar question ? |
On Wed, Nov 08, 2000 at 08:05:34PM +0100, Karim BELABAS wrote: > It's not a generic assignment: it's actually deferred until the loop body > is evaluated. And it works so that the loop index is automatically local to > the loop, i.e is restored to its former value when the loop ends. After > > x = 0; for (x=1, 10, print(x)) > > the value of x is 0. Vaguely related note: I think it is quite easy to allow definition of such *user-defined* constructs. The syntax may be like this: for_squares(x==init,last,func()) = { local(var_numbered(x)); local(n); n = ceil(sqrt(x)); while( n^2<=last, set_var_numbered(x,n^2); n=n+1; eval(func) ) } so that on entry x is set to be the variable number (or maybe it is better to alias it?), and func set to the string value of the corresponding argument... Ilya