Operator overloading semantics

Chris Pressey cpressey@REDACTED
Tue Mar 5 03:08:53 CET 2002


I've written a module (a behaviour) which allows the programmer to change
the operator overloading semantics of Erlang.

As overloaded operators are a double-edged sword, my question is, do you
think it would be wise to release this publicly?

The biggest 'con' is that the overuse and/or misuse of overloading makes
programs more difficult to reason about, maintain, and debug.

This is offset, though, by the facts that Erlang, like almost all
high-level programming languages, already has some overloaded operators
(e.g. + and - on floats and integers); and that this behaviour is a parse
transform; no one is required to use it, and when it is used, it should be
clear from the source (as with any parse transform.)

Also, appropriate use of overloading can make source code easier to read,
especially in the case of constructed numeric data types for which + - * /
have commonly understood meanings.  This is something for which I have a
need, but I don't imagine many other Erlang programmers really require it.

What do you think?  Should I upload this to the User Contributions area,
or is the Erlang world better off without it?  :)


More information about the erlang-questions mailing list