Local variables not so local within block



On 2012-07-22, Stefano Ferri <ferriste at gmail.com> wrote:

> I'm having some difficulties with a conflict between a local variable used
> inside a block construct and a global variable of different type. In
> particular, the conflict is between a matrix and an undeclared array.

The problem is that Maxima is, in Lisp terminology, a "Lisp-2". That is,
different kinds of stuff (value, function, array, rule) can all be
attached to a single symbol. In contrast, in a "Lisp-1", only one kind
of thing can be attached to a symbol. The Lisp-1 versus Lisp-2 debate
was active many years ago and the Lisp-1 crowd decamped to create
Scheme while Common Lisp was designed as a Lisp-2. I suppose that should
make everybody happy now.

Furthermore, Maxima's implementation of Lisp-2-ness is messy. block([a],
...) makes the value local to the block, but not a function definition
or array or rule. There's nothing about Lisp-2 that requires that, it's
just an oversight. Sorry about that. Changing this situation is probably
not too painful, but it does require some devoted focus.

Anyway ... my advice is, try to avoid putting multiple kinds of things
on Maxima symbols. (Yes, that's right, Maxima will actively work against
you in that respect. Sorry about that.)

I wrote some code to create lexical symbols in Maxima. Search the
mailing list archive for "blex" or "lexical block". I can say more about
that if you're interested.

best

Robert Dodier