Wiki article about maxima's treatment of arrays and functions?



[Michel Van den Bergh <michel.vandenbergh at uhasselt.be>, Mon, 15 Jan 2007 14:51:53 +0100]:
> > - a simple macro with_gensyms() to evaluate some body after ...
> >
> > - and function degensymify() that takes an expression and ...
> 
> This is a little bit of I am proposing in my wiki article
> 
> http://maxima.sourceforge.net/wiki/index.php/LexicalLayer

The main difference I see is that you want sanitization to be
automatic.  with_gensyms() and kin must be invoked explicitly, and
they are mainly used for writing macros.  Considering the case of f(x)
:= 'x, I think that it is really the author of the definition who
ought to say what s/he wants.

For the infamous s[t] example, I would have to write with my
utilities:

,----
| (%i16) reeval(with_gensyms([s,t], buildq([s,t], f(s,t) := s[t])));
| (%o16)                 f(s$1754, t$1755) := s$1754
|                                                   t$1755
`----

The above definition obviously works for a literal t as first
argument:

,----
| (%i18) f(t,1);
| (%o18)                                t
|                                        1
`----

Of course, as Maxima functions are not opaque, I can easily extract
the gensym and re-create the error formerly triggered by f(t,1):

,----
| (%i20) f(inpart(fundef(f),1,2), 1);
| 
| t\$1755 evaluates to 1
| Improper name or value in functional position.
| #0: f(s\$1754=t\$1755,t\$1755=1)
|  -- an error.  Quitting.  To debug this try debugmode(true);
`----

Best regards,

Albert.