Personally I love operator overloading, and having more control over memory
usage. But especially operator overloading. I think Java has been growing
up with the generics (templates) in 1.5. Now if it had operator
overloading it would be completely matured.
I have seen a lot of operator overloading i C++, and with the
exception of some use of "==" and "!=", I have never seen it used
appropriately. It is almost always used as some sort of short-hand
hack to save the programmer a few keystrokes at the expense of ending
up with incomprehensible code.
I do not doubt that there are legitimate uses for operator
overloading, but I personally never use maths libraries and rarely
find the need to do matrix or vector multiplication, so never see
it. For such a marginal field of "appropriate" use, I find the feature
completely unnecessary and, as it turns out, directly destructive to
the readability of source code.
Now, if you could have "operator definition" in stead of overloading,
that might have some uses, but the existing operators would have to
remain off limits. I could see some use in defining custom operators
such as $, or @, etc., but I suspect that this would also degenerate
into unreadability. The best way to find out, I suppose, would be for
some widely used prototype language to implement it, wait a few years,
and see how much of a mess it turned into. Do they still accept
suggestions for C++ features? said:
Judge for yourself, what's more intuitive:
String s1 = "hello";
String s2 = "hello";
if(s1 != s2)
System.out.printf("%s != %s", hello, hello);
This is a really bad idea as the basic notion that != and == compare
on object identity is exceedingly useful and I wouldn't want to have
to second-guess this functionality every time I need to use it.
Cheers
Bent D