Subject: Program stack overflow defining infix operator
From: Robert Dodier
Date: Fri, 7 Aug 2009 08:11:50 -0600
On 8/6/09, Robert Dodier <robert.dodier at gmail.com> wrote:
>> (%i1) infix("imp", 50, 50, clause, clause, clause);
>>
>> (%o1) imp
>> (%i2) "imp"(a, b):= not(a) or b;
>
>> (%i4) expand(a and b imp c);
>>
>> *** - Program stack overflow. RESET
>
> Looking at the stack trace, it appears Maxima is trying to
> evaluate a and b, for which it first needs a, which is
> bound to a and b, for which it first needs a, ... ad infinitum.
It turns out the Boolean functions have a nonstandard evaluation
scheme. In general Maxima has a 1-time evaluaton policy,
but functions can evaluate their arguments as much they want.
Re-evaluation triggers the stack overflow here.
At present the Boolean functions MAND, MOR, MNOT are
functions which quote their arguments (DEFMSPEC), then they
explicitly call MEVAL. (This situation has existed since before
I arrived on the scene.) It would be better to do away with the
DEFMSPEC and MEVAL and make them simplifying functions
instead. That would avoid this bug, and make the Boolean
functions more like other, mathematical functions in Maxima.
I'll put it on my to-do list, unless someone wants to talk me
out of it. Someone else could do it too, I won't complain.
best
Robert Dodier