array-lambda error with 5.30.0



On Thu, May 23, 2013 at 01:58:20AM +0000, Robert Dodier wrote:
> On 2013-05-22, Oliver Kullmann <O.Kullmann at swansea.ac.uk> wrote:
> 
> > (%i1) a:make_array(fixnum,3);
> > Evaluation took 0.0000 seconds (0.0000 elapsed)
> > (%o1) "{Lisp Array: #(0 0 0)}"
> > (%i2) L:buildq([a], lambda([x],a[x]));
> > Evaluation took 0.0000 seconds (0.0000 elapsed)
> > Maxima encountered a Lisp error:
> >
> >  In function SYMBOL-PLIST, the value of the first argument is
> >   #(0 0 0)
> > which is not of the expected type SYMBOL
> 
> OK, that's a bug introduced by commit 4260be98 (revision of NFORMAT).
> Here is a patch (I'll commit this).
> 
> diff --git a/src/nforma.lisp b/src/nforma.lisp
> index 02e56e5..f377514 100644
> --- a/src/nforma.lisp
> +++ b/src/nforma.lisp
> @@ -53,7 +53,7 @@
>         
>         ;; this next section is for the ordinary maxima objects that are tagged by
>         ;; their main operator or CAAR,  e.g. ((mplus) a b) has CAAR mplus ...
> -       ((setf p (get (caar form) 'formatter)) ;; find the formatter.  If there is one, call it.
> +       ((and (symbolp (caar form)) (setf p (get (caar form) 'formatter))) ;; find the formatter.  If there is one, call it.
>          (funcall p form))
>         (t form)))                      ; if there is no formatter. Just return form unchanged.
>  
> 
> Here is a session with the patched code.
> 
> (%i2) a:make_array(fixnum,3);
> 
> (%o2) "{Lisp Array: #(0 0 0)}"
> (%i3) L:buildq([a], lambda([x],a[x]));
> 
> (%o3) lambda([x],"{Lisp Array: #(0 0 0)}"[x])
> (%i4) L(0);
>

great, thanks!

> > Wrapping an array in a lambda-term is used quite a bit by us,
> > and I think it should work?
> 
> So something like L(1) to get an element of the array? Yes, that
> certainly should work. May I ask why you prefer that to simply
> writing a[1] ?
> 

For example, we have a function which assumes an argument h (like
homomorphism), and which uses h(x). Now there are circumstances, where
that function is given via an array, for example for performance
reasons. Or just an array is involved, and then you use something like
L:buildq([a],lambda([x], 2*a[x]+1));

Best

Oliver