Fix for $matrix (Was: "matrix([matrix([" returned with mat_function (Was: Re: Symbolic matrix power))
Subject: Fix for $matrix (Was: "matrix([matrix([" returned with mat_function (Was: Re: Symbolic matrix power))
From: Stavros Macrakis
Date: Tue, 29 Oct 2013 00:38:41 -0400
Hmm. GCL seems to support 200 arguments in eval, but not in apply:
(defun f (&rest x) x)
(setq l (do ((i 0 (1+ i)) (l nil (cons i l))) ((> i 200) l)))
(apply 'f l) => error
(eval (cons 'f l)) => correct value
I don't think rewriting $matrix can help. Rewriting meval/mapply might
help, but it would be bizarre to have to wrap all arguments with (quote
...), but maybe necessary for > 63 arguments ?!
The best fix would of course be to improve GCL.
-s
On Mon, Oct 28, 2013 at 11:27 PM, Robert Dodier <robert.dodier at gmail.com>wrote:
> On 2013-10-29, Stavros Macrakis <macrakis at alum.mit.edu> wrote:
>
> > (defun $matrix (&rest rows)
>
> >> But that only matters if an object is being *evaluated* where it
> >> shouldn't be. And sure enough, applying the 'matrix' function
> incorrectly
> >> re-evaluates its arguments.
>
> Excellent catch, spot on. However, the current version of $MATRIX is
> pretty recent, and it's written as a MFEXPR* because GCL allows only a
> small number of arguments -- 63 iirc. So it was easy to bump into
> something like matrix([1], [2], ..., [64]) => Lisp error: too many
> arguments. For the record: commit 9bcad16b9e.
>
> I suppose all Lisps must have a limit on the number of arguments, but
> aside from GCL, the limit is so big that nobody bumped into it. Is there
> a way to write $MATRIX which accommodates both a long argument list and
> ordinary evaluation?
>
> best
>
> Robert Dodier
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>