William Clodius <wclodius@lanl.gov> wrote:>Many programming languages allow the user to overload of language>defined operators. But a few languages also allow the user to define>their own operators. I would like to have some feedback on the>experience of others with user definable operators with respect to>specifying their syntax, associativity, precedence, semantics (e.g.,>side effects or not), etc.

First if a user overloads + - * / its important that the overloads
act like the original arithmetic operators. So using them for your
new multi precision numbers or rationals is good using them for
string operations is evil. Ideally the optimizer should be able
to say (a + b - b) is the same as (a). Further a += b is the same
as a = a + b except that a is only evaluated once. This reduces
the number of basic things that need to be defined.

Further, it's important to allow new operators. There are dot products
and cross products and we need symbols for both. Having something like
unicode as the symbolic base is ideal because computer math can look
like published math. Very brilliant people have worked on mathematical
symbolism for centuries and produced a highly readable
result. Throwing it away on abominations like sqrt for the radical
sign is pure evil.

And symbols need to be of variable size as in Tex. And we need symbols
for things like for loops and if statements which include the things
they operate on much like large sigma symbols and integral signs.

In math its name and conquer so people need to build their own symbols
easily and use them easily.
--