MFUNCTION-CALL: fix incorrect number of argument evaluations
These are very old Maxima bugs (present in 5.0) that were not present
in Macsyma.
MFUNCTION-CALL-AUX has been receiving a list of unevaluated args and a
list of the corresponding evaluated args. Presumably the idea is that
the args will be evaluated once before function entry, so
MFUNCTION-CALL-AUX wouldn't need to EVAL args itself when, say,
applying a lisp function or Maxima lambda expression.
The old MFUNCTION-CALL-AUX in Macsyma wasn't like that; it would only
receive a list of unevaluated args and it would EVAL them itself when
necessary.
One problem with the Maxima approach is that the args are always
evaluated, even when evaluation should be controlled by the Maxima
special form, mfexpr or lisp macro we are MFUNCTION-CALLing:
(%i1) tr_warn_bad_function_calls : false$
(%i2) foo () := bar (print (0), print (1))$
(%i3) bar ('x, 'y) := 123$
(%i4) foo ();
(%o4) 123
(%i5) translate (foo)$
(%i6) foo (); /* wrong */
0
1
(%o6) 123
or
(%i1) foo () := bar (print (0), print (1))$
(%i2) translate (foo)$
(%i3) :lisp (defmspec $bar (x) (declare (ignore x)) 123)
#<FUNCTION (LAMBDA (X)) {
5359B9DB}>
(%i3) foo (); /* wrong */
0
1
(%o3) 123
(%i4) transrun : false$
(%i5) foo ();
(%o5) 123
And what received evaluated or unevaluated args was inconsistent:
Maxima special forms and mfexprs would receive the unevaluated args
(after they were already evaluated separately), but the case of lisp
macros has been totally bogus because they would receive the already
evaluated args!
Another problem has been with bound vars: when applying the value of a
var to args, the args were being re-evaluated:
(%i1) tr_warn_bad_function_calls : false$
(%i2) foo () := block ([n : 0], bar (print (n : n + 1)))$
(%i3) bar : lambda ([x], x)$
(%i4) foo ();
1
(%o4) 1
(%i5) translate (foo)$
(%i6) foo (); /* wrong */
1
2
(%o6) 2
Now MFUNCTION-CALL-AUX handles arg evaluations itself, much like it
used to in Macsyma.
No problems with the test suite, share test suite or rtest_translator.
New tests have been added to rtest_translator.