Various (and almost completely unrelated) questions and opinions
David Gould
davidg@REDACTED
Wed Feb 21 08:31:53 CET 2001
On Mon, Feb 19, 2001 at 06:29:19PM -0600, Chris Pressey wrote:
...
> I've had some thoughts about overloading operators, btw. I think it's
Have you looked at Oberon? I am somewhat persuaded by the Oberon rationale
against overloaded operators. Oberon is roughly my idea of what a C level
language with objects should have been. They claim extreme simplicity is
a good thing. To back it up, the Oberon language specification is coherent
and complete in something like 28 pages. See other simple languages, eg
R5RS for contrast.
Anyway, the Oberon argument is that code should be understandable by
reading it. That is, what is being done and the cost of doing it should
be apparent by looking at it. The problem with overloading is that "A + B"
could mean anything, eg "blend these two 80MB images", and it is not obvious
from the immediate source what the heck is going on or what it might cost.
Not without finding the declarations of A and B and '+' and understanding
how overloading selects implementations, all of which in the worst case
(c++ again!) are stored in separate files in separate directory hierarchies.
At least for the Oberon system designers, this appears to work, they have
produced some pretty fantastic stuff that runs on ridiculously low
resources.
One of the things I like about Erlang is that it too has an emphasis
on "textual transparancy" and simplicity. Except possibly in how I/O is
really done...
> only of limited use unless you can have user-defined functions in
> guards. This is assuming that the semantics of any overloaded operator
> are expressed by a user-defined function, and that relational operators
> can be overloaded.
I like the rationale for the restrictions on guards, that they are
restricted to known time or constant time operations without side
effects. It means a less flexibility, but if guards could be arbitrarily
expensive, then people would start contorting code in other ways to avoid
using guards or something. A net loss I think.
-dg
--
David Gould davidg@REDACTED 510 536 1443
If simplicity worked, the world would be overrun with insects.
More information about the erlang-questions
mailing list