[Maxima] common lisp complex numbers, also common lisp rational numbers
smh at franz.com
Thu Mar 1 15:30:18 CST 2012
Henry Baker <hbaker1 at pipeline.com> wrote:
Now it might be a good idea to first _extend_ Common Lisp with Maxima
data types, and only then interpret/compile the Maxima language in
this extended language.
If you wanted to do this cleanly, you probably want to implement
Maxima data types in CLOS (object-oriented language for Common Lisp).
This is because CLOS has full generic functions, so it is easy to add
new datatypes to an already existing function. In a compiled
language like C++, this notion is called "overloading"; CLOS allows
overloading for _any_ generic function, not just for +,-,*,/,^, etc.
(Ummm, CL is also a compiled language. But nevermind...)
Not _every_ generic function can be overloaded in arbitrary ways.
Adding a specialized primary method to handle a new class of argument
will not necessarily work if the gf has :around, :before, or :after
methods. Those methods will also see the extended argument classes and
must be prepared to accept them.
A more serious problem is that the functions +,-,*,/,^, etc. are _not_
specified to be generic functions. They are _allowed_ to be gfs, but it
was a performance choice by X3J13 (wanting to define an
industrial-strength programming language) not to require all functions
One could of course modify an exiting CL implementation to make all the
desired functions generic, but this would be a larger,
more-destabilizing, and more performance-killing job than one first
might think. But I do agree it would be a neat thing to have!
More information about the Maxima