I agree on not letting just anyone overload operators. However, there is already operator overloading for String (+). I don't see any problems adding it to two other numerical classes in the core API. It's already added to the primitive wrappers through boxing/unboxing, so why not for these two?
Joined: Oct 13, 2005
. . . and in this case it would be intuitive. The overloaded + isn't intuitive for Strings.
Personally I think I would enjoy operator overloading. It can greatly increase readability of code. Of course it can and will be widely abused; but the same is true for the sub-typing system. Should Java have gone without inheritance?
The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
Joined: Mar 22, 2005
Inheritance is actually a feature I, for one, rarely use. Interfaces, OTOH, are a great thing.
One feature that was rushed in and caused a lot more problems that it solved (IMO) were the wildcard generics.
Joined: Oct 13, 2005
Was generics rushed in at all? They took their time writing generics, nice and slowly. 9 years too slowly If generics had been available from the start, it would have been based on reification, not erasure, and it would have been easy to understand.
Ulf Dittmer wrote:IMO, overloading is one of the more evil features of C++. I sure hope it never makes it into Java in a general way (meaning, where everyone can define what "+" means for class X).
Actually, operator overloading came from ADA before C++, and may have come from something before ADA. But I agree that it is evil. I don't see it having any value except for numeric data types. I spent ages working on a Money class with proper overloading, and it was never perfect.
I think we'd be better off with language-defined abstract numeric data type that has the usual arithmetic overloads, and let us implement the required functions.
Still, its not clear what the proper meaning of when a is Complex and B is Money.