part functions



> I would love to see the semantics of that formally defined.

What exactly is the issue?  In substpart(new,expr,partspec...), expr is
evaluated first, then the part is extracted and assigned to the global
variable Piece, then new is evaluated, and a new expression constructed
with that new value in the specified part.

> So piece acts like a reference in a global variable.

Piece *is* a global variable:

   expr: x^2+a
   part(expr,1,2)
   piece => 2

> So if part(a,1)+part(b,2) is executed, what piece points to is
> implementation dependent, or is the semantics of the above
> statement defined somewhere regarding evaluation order?

I don't know if it's documented explicitly anywhere, but Maxima (like
Lisp) always evaluates normal function arguments (in this case, the
arguments to "+") left to right.  Simplification happens after
evaluation, so the order won't be changed by simplification.
part(expr,1)+part(expr,1,2) => x^2+2, and the value of Piece is 2.

Some functions evaluate their arguments themselves -- notably substpart
and ev.  In substpart, the second argument is evaluated before the
first; in ev, the modifier arguments are evaluated before the first:

   substpart(print(1),[print(2)],1)
   ev(print(1),x=print(2))

both print 2 then 1.

Did I understand your question, and did I answer it satisfactorily?

       -s