bug in mdefmacro?



Hi Volker,

> (C1) foo(x)::= block( [x:ev(x)], print(x) )$
> (C2) block( [a:1], foo(a) );
> 1  (this is what I want)
> (D2)                                   1
> (C3) block( [x:1], foo(x) );
> x  (not wanted)
> (D3)                                   1

I think this is working just as intended. A Maxima macro
is almost the same as an ordinary function with these
differences: a macro quotes its arguments, and its return
value is evaluated in the environment from which it was called.
Another factor is that Maxima binding is dynamic, not lexical.
I think these considerations explain the observed results.
Stavros and/or Richard can correct this if it's wrong.

To keep the local symbol x from hiding the global x
(an artifact of dynamic binding and not specially related
to macros), maybe you can change the local symbol to x%
or something.

By the way I have recently revised and expanded
the description of macro functions in the reference manual.
See ::= in Operators.texi and buildq and macroexpand
in Functions.texi.

best,
Robert Dodier