Interesting!
The use of the $name convention could be entirely replaced by using the
common lisp package system.
That is, if you have a maxima-user package with nickname mu, then instead
of $sin you could have mu:sin.
This would require changes to the parser, stripdollar, and a few other
places. It might be fun to see how few places really have to change. Maybe
it could be done at the same time as allowing strings, instead of strange
symbol-names.
If you did this, maybe the rest of the common-lisp package system could be
used, with the modification that the package suffix could be changed from
the character : to the character @.
This could, I think, be changed by a two-line read-table modification.
I think it is a plus if the common lisp version of maxima takes advantage
more of common lisp.
(Another example of this would be to replace ((rat) 1 2) with common lisp
rationals. tracking down all usages of this may be elusive.)
RJF
> -----Original Message-----
> From: maxima-admin at math.utexas.edu
> [mailto:maxima-admin at math.utexas.edu] On Behalf Of Robert Dodier
> Sent: Wednesday, August 16, 2006 7:56 PM
> To: Maxima List
> Subject: User-level namespace system for Maxima
>
> Hello,
>
> I have been working on a user-level namespace system for Maxima.
> Here is the code I've churned out thus far:
> http://maxima.sourceforge.net/misc/namespaces.lisp
> and here are some notes about it:
> http://maxima.sourceforge.net/wiki/index.php/User-level%20name
> spaces%20in%20Maxima
> <http://maxima.sourceforge.net/wiki/index.php/User-level%20nam
> espaces%20in%20Maxima>
>
> I don't suppose this is very clever, and there are some
> obvious misbehaviors.
> Mostly I'd just like to get the ball rolling. Comments welcome.
>
> There has been discussion about using CL packages in Maxima,
> but it seems to have been focused on reworking Maxima internals.
> See:
> http://maxima.sourceforge.net/wiki/index.php/Maxima%20package%
> 20system
> <http://maxima.sourceforge.net/wiki/index.php/Maxima%20package
> %20system>
>
> FWIW
> Robert
>
> PS. Here is a session log using the code. foo.mac is shown on
> the wiki page mentioned above.
>
> (%i1) load ("namespaces.lisp");
> (%o1) namespaces.lisp
> (%i2) import (foo);
> (%o2) [[foo at g, foo at f]]
> (%i3) foo;
> (%o3) #<$FOO package>
> (%i4) symbols (foo);
> (%o4) [foo at g, foo at f, foo at h, foo at my_constant]
> (%i5) external_symbols (foo);
> (%o5) [foo at g, foo at f]
> (%i6) my_constant : 1 - %pi;
> (%o6) 1 - %pi
> (%i7) foo at my_constant;
> (%o7) 1729
> (%i8) h(x) := (1/2) * x^2;
> 1 2
> (%o8) h(x) := - x
> 2
> (%i9) apply (dispfun, [f, g, h, foo at h]);
> (%t9) foo at f(x) := foo at my_constant sin(x)
>
> n
> (%t10) foo at g(n) := expand((n! + foo at f(a)) )
>
> 1 2
> (%t11) h(x) := - x
> 2
>
> (%t12) foo at h(z) := foo at f(z) - foo at g(2)
>
> (%o12) [%t9, %t10, %t11, %t12]
> (%i13) f(%pi/4);
> 1729
> (%o13) -------
> sqrt(2)
> (%i14) g(3);
> 3 2
> (%o14) 5168743489 sin (a) + 53809938 sin (a) + 186732 sin(a)
> + 216
> (%i15) h(u - v);
> 2
> (u - v)
> (%o15) --------
> 2
> (%i16) foo at h(u - v);
> 2
> (%o16) - 1729 sin(v - u) - 2989441 sin (a) - 6916 sin(a) - 4
>
>