Local variables not so local within block



Stefano Ferri <ferriste <at> gmail.com> writes:

> Thanks for your reply. I've followed some discussions on the
> mailing list in the past about some inconsistencies with the block
> construct, but the problems were related to the arguments passed
> to functions (e.g. f(x):=block([],....) in wich x was not really
> local). 

As it happens, in Maxima, function arguments are local variables
in exactly the same way that variables in block are local.

>> Furthermore, Maxima's implementation of Lisp-2-ness is messy.

> Isn't this a bug??

Yes.

> I always give different names to different kind of variables,
> because I had some problems in the past with lists and undeclared
> arrays with the same, so I started to use different names. But if
> one writes a program and it grows and becomes more complex, there
> will be a lot of functions and functions calling other functions,
> and it becomes difficult to always use different names and remember
> wich have been used, when this names should be local.

Yes, that's a very good argument for lexical scope -- it
makes large programs more comprehensible.

> I read about blex, but it use gensym, right? If so, wich is the
> minimum Maxima version working with blex? 

Well, the implementation I recently posted
(http://permalink.gmane.org/gmane.comp.mathematics.maxima.general/38899)
doesn't depend on the existence of a Maxima gensym function.

best

Robert Dodier