Related articles |
---|
User definable operators wclodius@lanl.gov (William Clodius) (1996-12-14) |
Re: User definable operators fjh@murlibobo.cs.mu.OZ.AU (1996-12-15) |
Re: User definable operators cef@geodesic.com (Charles Fiterman) (1996-12-15) |
Re: User definable operators mslamm@pluto.mscc.huji.ac.il (Ehud Lamm) (1996-12-15) |
Re: User definable operators ddean@CS.Princeton.EDU (1996-12-15) |
Re: User definable operators dennis@netcom.com (1996-12-15) |
Re: User definable operators fjh@mundook.cs.mu.OZ.AU (1996-12-15) |
Re: User definable operators burley@gnu.ai.mit.edu (Craig Burley) (1996-12-18) |
Re: User definable operators jdean@puma.pa.dec.com (1996-12-18) |
[17 later articles] |
From: | Charles Fiterman <cef@geodesic.com> |
Newsgroups: | comp.compilers |
Date: | 15 Dec 1996 16:15:39 -0500 |
Organization: | Geodesic Systems |
References: | 96-12-088 |
Keywords: | design |
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.
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.