Wiki article about maxima's treatment of arrays and functions?
Subject: Wiki article about maxima's treatment of arrays and functions?
From: Albert Reiner
Date: 14 Jan 2007 22:52:17 +0100
> Dan Stanger wrote:
>
> > While a single namespace is bothersome, it is really quite simple
> > to replace all variables appearing in input expressions, with ones
> > which cannot occur in users input.
(Disclaimer: It seems I didn't get Dan's original mail, so maybe I
missed some discussion.)
Is this really so simple? I suppose this refers to gensyms, in which
case I see two issues:
- If a gensym is part of something that is returned, the user can get
hold of it by inpart() and similar operations; however, this is only
a concern with a malicious user who tries to break things. I would
not be concerned with this, but other people's notion of robustness
may differ.
- If you write an expression containing gensyms to a file, they will
appear with their (not necessarily unique) names. Again reading
that file into Maxima creates Maxima variables that are not gensyms.
When I started to work with Maxima and used it a lot, I wrote quite a
bit of code to add the kind of constructs that fit my way of
thinking. The two main definitions for dealing with gensyms were
- a simple macro with_gensyms() to evaluate some body after binding
some symbols to gensyms; these gensyms had names derived from the
original symbols (important for readability) and recorded the
original symbol recorded as a property
- and function degensymify() that takes an expression and replaces all
gensyms by interned Maxima symbols (with names obtained from the
symbol originally given to with_gensyms()), optionally wrapping the
whole thing in a with_gensyms() form. The result is safe for
writing to a file, as far as I can tell.
In case of interest, I can put up my utilities.max somewhere.
Regards,
Albert.