[1057] in java-interest
Re: overloading of operators
daemon@ATHENA.MIT.EDU (Walter Smith)
Thu Aug 17 20:40:35 1995
Date: Thu, 17 Aug 1995 10:55:16 -0800
To: java-interest@java.sun.com
From: wrs@newton.apple.com (Walter Smith)
One more and I'm outta here...
1. Obviously, operator overloading on numeric operators can make sense for
numeric types.
A. Even so, there's already confusion about the built-in type
conversions, and adding more combinatorial cases won't make it
any simpler to figure out what's happening. (Look at Modula-3's
decision to make unsigned integer operations function calls to
avoid the mess you get by making unsigned a type modifier.)
B. There's no way to get the compiler to limit you to overloading
numeric types, so somebody will think it's clever to use, for
example, the left shift operator to mean "print". And somebody
else will have to understand that code.
C. Who's to say what a "numeric operator" is? Is '='? Is '<'?
Is '&'? What does '&' mean for a complex number? Wouldn't
'<' be great for strings? Hmm, is '<' case-sensitive or not?
(I made that mistake myself.)
2. The argument that "because some people will abuse the feature nobody
should be allowed to have it" is mostly correct, but largely irrelevant.
A. Some people _will_ abuse the feature. It doesn't bring enough
advantages to outweigh the horrors that occur when it's misused.
If you're reading this list, you're probably a better programmer
than most. Programming skill varies tremendously (there are
multiple studies to prove it). Have some compassion for those
less skilled than yourself. Don't give them the rope to hang
themselves (and their coworkers and customers).
B. "If it helps anybody, put it in" is not a good way to design
_anything_. You have to look at the entire context of the
language to make the decision (and the argument). Java is
still simple. That's one of its main features. Every
new feature or construct you add detracts from that most
important characteristic.
I think we've reduced the problem to a matter of taste. We've all had our
say--leave it up to the language designers to decide (in this case, it was
undoubtedly way too late to change something like this anyway).
Oh, and since someone asked--the language designers get to decide, because
they're the language designers. If you don't like it, feel free to design
your own. This is definitely one area where too many cooks spoil the
broth.
- W
---------------------------------------------------------------------------
Walter Smith Internet: wrs@apple.com
Newton Software AppleLink: WALTER.SMITH
Apple Computer, Inc. PGP key at ftp://ftp.apple.com/pub/wrs/PGP-key.asc
+1 408 974 5892 E1 20 C3 0A DE 27 89 06 0B 35 08 65 0C FB A7 41
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com