[94] in java-interest
Re: Overloading of "+" for string concat
daemon@ATHENA.MIT.EDU (todd@mars.clarit.com)
Thu May 18 13:57:58 1995
Date: Thu, 18 May 1995 12:30:23 -0400
From: todd@mars.clarit.com
To: java-interest@java.Eng.Sun.COM
Hi all,
I'd like to voice my agreement with Scott Hudson's critique of
the overloaded + operator. When I read the Java specification paper,
one of the few "design burps" I encountered was exactly this issue.
By "design burp" a mean a non-orthogonal exception to some design point.
The design point in question is that Java does not support operator
overloading, EXCEPT in this one specific case. The problem is that
this case is clearly just for syntactic convenience.
A related burp is the implicit conversion to String, based on the
"magic" method toString(). This is an exception to the Java design point
that limits implicit conversions to specific simple cases (see section 7.2).
This is a more troubling flaw, since it has direct consequences to the
underlying semantics of the language, instead of being a purely syntactic
matter.
I dislike these choices that make certain types "more loved" than others.
These points clearly give class String "more important than thou" status,
since no other class has the benefit of overloaded operators or
auto-conversion methods.
The Java designers should seriously rethink both of these points.
Scott's suggestion that a new concatenation operator be chosen is
well-advised, and I quite like "::" to fill that spot (it's so reminiscent
of ML!). The auto-conversion burp is more difficult to correct, but also
more important to fix from a language design standpoint, since it provides
quite a bit of power for a very special case. That special case is admittedly
quite common, but this solution will likely cause difficulty for any
formal semantic model of Java.
I'll close by stating that, modulo these design burps and a couple others,
Java is quite thrilling to a language purist (and rabid devotee of
Scheme/ML/Dylan/etc) who wishes clean languages would grow in popularity.
Java might by just the right portal to get more traditional hackers into the
safe-language fold. (Dylan is attempting the same thing, but Java is a much
more comfortable first step for the legions of misguided C++ nuts out there).
.T.
. . . Todd V. Jonker . . . . . Systems Designer . . .
. . . todd@clarit.com . . . . . CLARITECH Corp. . . .
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com