Complicated objects in Maxima



On 5/18/2012 6:53 AM, Steve Haflich wrote:
> ....

>    When code asks a question about
> a node, the answer becomes class based.
.....
>
> Under such a regimen, an operation that simplifies an expression that is
> the addition of two subexpressions would become a generic operation that
> uses the classes of its argument subexpression, and what is known about
> itself as represented by its own class.
>
...

I think this is similar to the representation in Maple, at least in the 
data structuring direction,
though probably not in the method dispatch.
That is, in Maple, there are structures like
"power"   with 2 more slots, so that   x^y  would be   [power_tag,x,y].
a+b+c would be  [plus_tag,3,a,b,c]   where the 3 is an argument count.

There is, I guess, a tag for f(x,y) like
[user_function_tag,f,2,x,y]

Years ago the count tag space was 16 bits, leading to problems for sums 
of more than 2^16 terms.
It has been enlarged.

Nevertheless the use of lists is hardly inevitable.  Also, instead of 
storing the "head" of the expression
plus, times, sin, cos,log....  explicitly as a lisp atom in the 
expression, it could be stored somewhere
implicitly.  This would mean in maxima lisp terms, computing (type_of 
E)  instead of (caar E).
and having (simplify ....)  be a method associated with E,  rather than 
essentially  (apply (get (caar E) 'op) E).

An issue that messes up this situation is that the identification of the 
appropriate method in maxima is
often dependent on information that is not in the heads or types of the 
arguments.  For example,
the setting of relevant flags.  A simple method might need to look at 
flags like numer, expop, radsimp, etc.
The point here is that the "right thing to do" does not just fall out in 
the wash because you are using
object-oriented programming.  OO could have some benefit in an overall 
organizational sense;  (at least I hope
it would), and it probably would not make the program much slower.  It 
might make some data structures
larger, and others smaller.

People have implemented systems along these lines, more or less.  e.g. 
Axiom.


RJF