[985] in java-interest
Re: Operator Overloading
daemon@ATHENA.MIT.EDU (Tako Schotanus)
Wed Aug 16 07:40:03 1995
Date: Wed, 16 Aug 95 09:49:35 +0200
To: Thomas.Ball@Eng.Sun.COM (Thomas Ball), krom@cgi.com
From: Tako Schotanus <Tako.Schotanus@bouw.tno.nl>
Cc: java-interest@java.Eng.Sun.COM
At 09:25 15-08-95 -0700, Thomas Ball wrote:
>> 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.
>
>Yes, but isn't it interesting that the only examples operator-overloading
>proponents use are either the one above or numeric types such as matrices?
>Java already supports the above as a special hack for Strings. You'll
>find it much more difficult to come up with a compelling example using
>any of Java's AWT or Net classes.
Because there's no logic in it! Why is the most compelling example of using
a spoon to eat with it and not digging with it? You could, but you normally
don't. Why? Because everyone sees that a shovel would be much faster and
besides you wouldn't look as silly ;)
I think that inuitively the '+'-operator could be used to add or concatenate
two objects of the same type.
BTW: Everyone against op-overl. would have to live without the current
"hello" + " world" construct, but I guess you can.. :)
- Tako
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
_/ Tako Schotanus, TNO Bouwinformatica _/
_/ work: Lange Kleiweg 5, 2288 GH, Rijswijk, NL, tel: +31-15-842393 _/
_/ home: van Hasseltlaan 352, 2625 HZ, Delft, The Netherlands _/
_/ E-mail: sst@bouw.tno.nl - URL: http://huizen.dds.nl/~quintess _/
_/ Never let a dictator rule with peace; let peace rule like a dictator _/
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com