Overloading (was Re: Algorithmic lists )
Tue Oct 17 12:51:26 CEST 2000
"Vlad Dumitrescu" <> writes:
>>No, we didn't really think it is such a good idea. It is VERY NICE to
>>be able to look at an operator and KNOW what the argument and result
>>types must be.
>One alternative solution (which I don't really like much either) would be to
>allow definition of infix functions, and use for example "X @+ Y" instead
>of "add(X, Y)"
There are a couple of problems with this:
1. To make it general you would have to make a transformation like
"X @+ Y" --> '+'(X, Y)
otherwise it would be a pain to define, and remember, the operator/name
2. Today the compiler makes the transformation
"X + Y" --> erlang:'+'(X, Y)
for operators. It just hasn't been standardised.
3. If the transformations go to local functions it really it that
4. There is a proposal for standard Erlang
(Proposal 16 "Local function names") which together with some suitably
defined rewrite rules for operators, or just crafty synonyms would
probably do the trick.
5. I don't LIKE overloaded operators!
6. And, as I said before, without static typing it not really that
useful as it is difficult to control. In Erlang you overload function
names but you qualify them with modules when they ork on different
things. Perhaps "X @foo:+ Y"? :-) :-)
7. As the great Cato once said "I still think that operator overloading
should be burned!"
Robert Virding Tel: +46 (0)8 545 55 017
Alteon Web Systems Email:
S:t Eriksgatan 44 WWW: http://www.bluetail.com/~rv
SE-112 34 Stockholm, SWEDEN
"Folk säger att jag inte bryr mig om någonting, men det skiter jag i".
More information about the erlang-questions