mttc said:
my suggest is simple (I not mention it above):
Java start to support Operators Override in new nice way. who say the
Operators is only "==,-,*..", we can add ability to declare new
operators, like eq or === or what we convince. so from now we can
write like this: if(str1 equal str2).
If operator overloading is controversial, creation of new operators is
even more so. At least '<<' has a clear basis point for code (it shifts
characters to the left), but what the heck is `a $ b' supposed to mean?
Your proposal also involves using alphanumeric sequences as potential
operators, which is very bad. Would `eq' be an operator only if it was
in an "operator position"? If not, then `eq' appearing outside would
have to be an error, breaking backwards compatability (!). If so, then
parsing is quite a bit harder, and unary operators become untenable: is
`plus(...)' a plus operator on the parenthetical expression or a call to
the method plus?
Furthermore, what is a candidate to be a potential operator? It seems
you might want + and -, but what about ±? §? ¢? ¤? — (not -)? ö? è? ß?
(There should only be two accented characters there; if not, change your
encoding to UTF-8.) In short, what characteristics would make a series
of characters potential operators?
notice that with mmodern environment like NETBean the eq is got
another color, so is well reading. I glad to hear another Idea, but
stay with this ugly code, is Stop java to reach more Developer. you
must think that code like "if(str1 eq str2)" is match faster that
existing str1.equal(str2).
How would NetBeans know that `eq' is an operator? It's also this point
that your text is throwing InternalParseErrors that I can't catch [1]...
Also if we thinking fresh, we can add directive to java compiler and
start new Java syntax, or Java Extended or what you like, but get Dev
free from narrow brain.. give us the freedom
You've not really added much on this subject. The following recent
thread had several different implementation ideas discussed:
<
http://groups.google.com/group/comp..._frm/thread/c05f38c9e4c61b10/2b4ecbd2ad02b9ac>
An older thread that discussed operator overloading in more detail was
this one:
<
http://groups.google.com/group/comp..._frm/thread/444250a94b1020c6/6b9b3d797281a3ff>
I've grown more in favor of operator overloading personally myself, but
I think even the strongest proponents would concede that there are very
few tools which can make code more indecipherable than operator
overloading. One has to balance expressiveness with potential for
misuse. For example, in some cases, it can be useful to overload the
comma operator, if you want to have a |matrix[row, column]| syntax or a
(really advanced) |"%s, %s" % (a, b)| sprintf-like functionality
(derived from python). That said, overloading the comma operator
irrationally leads you down the road to compiler hell. It's extremely
powerful but at the same time extremely easy to abuse.
[1] Sorry for the bad pun, I just couldn't resist.