initialization of local variable



Dnia Sat, 30 Jan 2010 14:02:11 -0800, R Fateman napisa?(a):

> 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


Thx for answer.
You are right that it is clear for people which know Lisp.
It may be difficult for people which start from Maxima without 
understanding of Lisp syntax.
It is well explained in Lisp doc.

Regards

Adam

PS

first example was the same as third ,
 it should be like :
1. initialization inside list ( without using other local variables)

 f1(x):=block([var1: 1, var2: x], var2);