[955] in java-interest
Re: Operator Overloading
daemon@ATHENA.MIT.EDU (Kevin Krom)
Tue Aug 15 21:48:33 1995
Date: Tue, 15 Aug 1995 10:49:26 +0500
From: krom@cgi.com (Kevin Krom)
To: java-interest@java.sun.com
I'm going to go against the grain and vote "Yes" to operator overloading.
I am the first to admit that it can be abused, resulting in messy and hard-
to-follow code, but there are very few language features that can't be abused
by *someone*. When used properly, operator overloading makes code cleaner
and simpler to follow. Which of these is simpler to understand?
String a = "Hello ";
String b = "world.";
String c = a + b;
or
String a = "Hello ";
String b = "world.";
String c = new String(a);
c.concat(b);
To me, the first example is more intuitive and obvious.
As far as misuse of operators are concerned, overloading "+" to do something
non-obvious is as bad as a mis-named function called "append" or "concat" that
does the same non-obvious thing.
On the other hand, that binding of "new" has got to go... :)
--
Kevin M. Krom, Software Engineer Phone: (412) 642-6900 x242
Carnegie Group, Inc. Fax: (412) 642-6906
5 PPG Place, Pittsburgh PA 15222 Email: krom@cgi.com
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com