[1047] in java-interest
operator overloading
daemon@ATHENA.MIT.EDU (Thomas Breuel)
Thu Aug 17 18:42:31 1995
Date: Thu, 17 Aug 1995 12:16:57 -0700
From: <tmb@almaden.ibm.com> (Thomas Breuel)
To: java-interest@java.sun.com
In-Reply-To: <199508151632.JAA16311@webrunner.neato.org>
Reply-To: <tmb@almaden.ibm.com>
I don't feel that strongly about having overloading in the language,
operator or otherwise, but the discussion on this point so far
hasn't made a lot of sense to me.
First of all, I thought Java already supported overloading for
methods. But most of the reasons people cite against operator
overloading are reasons against overloading in general.
Arguments that overloading makes it hard to figure out what code
actually gets invoked at a particular point in a program are pretty
spurious in an object-oriented language anyway. Method dispatch is
even worse in this regard. If you want a clear, local
correspondence between name and function, don't do OOP.
Overloading of standard built-in operators is useful in a very limited
set of circumstances: for numerical types, for array-like types, and
for function-like types. When used properly, it actually contributes
to the readability of code. When used improperly, it can make a mess
of programs, but this is true of many features in Java or C++.
Arbitrary language restrictions aren't going to help you much with
poor programmer training.
I'm not convinced that Java should have overloading at all. But if
you have gone through all the trouble and added overloading, you might
as well allow overloading of operators, which adds no language
complexity.
Thomas.
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com