[1023] in java-interest
Re: Operator Overloading
daemon@ATHENA.MIT.EDU (Tom Wheeler)
Thu Aug 17 01:30:26 1995
Date: Wed, 16 Aug 95 19:32:27 EDT
From: tomw@intelligraphics.com (Tom Wheeler)
Reply-To: tomw@intelligraphics.com (Tom Wheeler)
To: java-interest@java.Eng.Sun.COM
On Wed, 16 Aug 1995 16:24:44 -0800 you wrote:
>I think this is getting rather off-topic, but I can't shut up quite yet...
>
>>Detractors argue that the [un-overloaded version] is
>>more readable because you _know_ what SomeFunc() and AnotherFunc()
>>do - you don't have to guess at their meaning.
>
>In other words, my position is the _opposite_ of what you said. The point
>is, you _don't know_ what any functions do without a long study, and you
>should never be allowed to forget it!
Okay, so basically you don't like operator overloading because it requires
you to remember that they too don't necessarily have "defined" meanings.
That's certainly reasonable, but I don't see that it necessitates
banning overloading - see below.
>>Operator overloading
>>is easier to abuse, true - but because operators have (typically)
>>well-defined meanings it should also be easier to adhere to those
>>meanings.
>
>On the contrary. Because operators have well-defined meanings, it is
>_more_ confusing when they are overloaded. The whole point is that you
I don't understand this. Given that '+' means addition, why is
Complex a, b;
...
return a + b;
any more confusing than "return a.AddComplex (b);"?
>The only "well-defined meaning" of + in C++ is that it adds two numbers of
>built-in types. That's it. (Even _that_ isn't very well defined, judging
>from the number of times I have to look at the type-conversion table.)
True. But the "well-defined meaning" of '+' that we all learn in second
grade is that it means addition. Later we learn how to apply it to different
kinds of numbers (gosh darn, operator overloading in mathematics!) of course,
and those of us who become programmers learn that it also means concatenation
when applied to strings (in certain languages). Why keep people from using
'+' to mean "add two Complex numbers"?
Regards,
Tom Wheeler
tomw@intelligraphics.com
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com