[995] in java-interest

home help back first fref pref prev next nref lref last post

RE: Operator Overloading

daemon@ATHENA.MIT.EDU (muzo)
Wed Aug 16 17:43:55 1995

Date: Tue, 15 Aug 95 16:51:16 UT
From: muzo  <MuzoK@msn.com>
To: java-interest@java.sun.com

It looks more obvious to you because you have this preconception that '+' 
should do string
concatenation. But nowhere it is said to be so other than 
the actual implementation of the op+ in string.
To it might make sense to 
have op+ to add the numeric values of the strings produce an integer. 
With 
operator overloading you get the added benefit of deceiving comments in your 
code. Like "the 
following line adds the item to the list" when it removes 
the item.

My vote is against operator overloading.

----------
From: 	
owner-java-interest@java.sun.com on behalf of Kevin Krom
Sent: 	Monday, 
August 14, 1995 10:49 PM
To: 	java-interest@java.sun.com
Subject: 	Re: 
Operator Overloading

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.

-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post