strangeness: constructing subscripted functions



Hello,

Here is some strange behavior, reported by a user.

foo [x] (y) := x * length (y);
foo [3];
 => error: length called on atomic symbol y

Instead maybe I'd hope to see lambda([y], 3 * length(y)) .

To construct the lambda expression for foo[3], Maxima evaluates
(via MEVAL) the right-hand side. So length is called but barfs since
y is not yet bound to anything.

I'll take this opportunity to propose that Maxima should be less
aggressive about evaluating the right-hand side. How about calling
MEVALATOMS instead of MEVAL. Yes / no / maybe ??

Maybe CONSTLAM should substitute for values of the
subscript variables instead of calling MEVAL-something.
That would differ from MEVALATOMS although it is not clear
to me just how it would differ.

FWIW & thanks for your comments.

Robert Dodier

PS. Here is a patch to put the above proposal into action.

--- src/mlisp.lisp      21 Jun 2008 21:14:06 -0000      1.66
+++ src/mlisp.lisp      15 Jul 2008 03:09:39 -0000
@@ -1899,7 +1899,7 @@
 (defun constlam (x &aux (lam x))
   (if aexprp
       `(,(car lam) ,(cadr lam) ,@(mbinding ((mparams (cadr lam)))
-                                          (mapcar #'meval (cddr lam))))
+                                          (mapcar #'mevalatoms (cddr lam))))

       lam))