There is a choice to be made as to the environment in which the right
hand sides of those assignments should be made.
Lisp allows either, via let or let*
Let* does sequential binding. Let does them "in parallel" and
therefore var2 cannot be initialized in terms of the var1 just defined.
It would use some other (global) var1, if there were one. block()
works like let() in lisp.
If you want sequential binding, I guess the simplest solution is what
you showed..
block([var1,var2], var1: ..., var2: ...
one could define another version of block via macro expansion to do
that, I suppose.
I think this behavior of block is "known" but perhaps not "well known".
RJF
Adam Majewski wrote:
> Hi,
>
> I have found ( maybe it is well known but I have not found it in doc)
>
> that local variable can be initialized :
>
> 1. inside list :
>
> f1(x):=block([var1: 1, var2: var1+x], var2);
>
> 2. after declaration (it is probably the best form ):
>
> f2(x):=block([var1, var2],
> var1: 1,
> var2: var1+x,
> var2);
>
>
>
> but local variable can not be usued inside declaration to init other
> local variables:
>
> f3(x):=block([var1: 1, var2: var1+x], var2);
>
> f3(1) gives var1+1
>
>
> Is it well known ?
>
> Adam
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>