macro returning a nounform = infinite loop?



On Tue, Apr 24, 2012 at 07:31, Barton Willis <willisb at unk.edu> wrote:

> Ordinary function that returns a nounform--OK:
>
> (%i13) f(x) := funmake('f,[x])$


This does not return a nounform, just an expression (which it doesn't
evaluate).  If this were a macro, it would return the same expression, then
evaluate it, hence the infinite recursion.

(%i1) display2d:false$
(%i2) f(x);
(%o2) f(x)             <<< regular function call
(%i3) 'f(x);
(%o3) 'f(x)            <<< nounified function call
(%i5) funmake('f,[x]);
(%o5) f(x)            <<< regular function call
(%i6) funmake(nounify('f),[x]);
(%o6) 'f(x)            <<< nounified function call
(%i7) fmac(x)::=funmake(nounify('fmac),[x])$   <<< macro returning
nounified function call
(%i8) fmac(4);
(%o8) 'fmac(4)           <<< no problem

The buildq works because it is returning the expression "funmake( FFF,
[XXX] ), which is then evaluated at main eval time (not macro
expansiontime).

             -s




> Macro that returns a nounform---infinite loop:
>
> (%i15) g(x) ::= funmake('g,[x])$
>
> (%i16) g(1);
> Maxima encountered a Lisp error:
>  Error in PROGN [or a callee]: Bind stack overflow.
>
> What's the story?
>
> --bw
>
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>