I got all the bitwise operators working using the new ShortcutExpr model which maps to methods. Plus I reworked JCodeAsm to generate the correct bytecode optimizations for those cases. Soon as fix some of the auto-cast stuff, I should be able to move most of the BinaryExpr operators to ShortcutExpr.
One thing that really bothers me is that C, Java, and C# all have this weird precedence for bitwise operators which is lower than equality or relational operators (I think it is a holdover from C days where non-zero was true)...
It is the same as C/Java/C# except that we move bitwise & | ^ up above relational operators and make | and ^ the same precedence.
Do you guys agree? Doesn't seem like a change that would really bother or trip up hard-code Java or C# programmers.
johnWed 14 Dec 2005
I understand what <=> does, but what is the point of having it? I don't think it's a necessary operator and it doesn't seem like something anyone would ever use. Especially since we have the full set of other comparison operators.
brianWed 14 Dec 2005
I guess it really isn't needed. But it is trivial to implement, and seems like it should be present since it the "master operator" for all comparisions.
I vote to keep it, although if you and Andy are against it, I wouldn't be upset about axing it.
brian Tue 13 Dec 2005
I got all the bitwise operators working using the new ShortcutExpr model which maps to methods. Plus I reworked JCodeAsm to generate the correct bytecode optimizations for those cases. Soon as fix some of the auto-cast stuff, I should be able to move most of the BinaryExpr operators to ShortcutExpr.
One thing that really bothers me is that C, Java, and C# all have this weird precedence for bitwise operators which is lower than equality or relational operators (I think it is a holdover from C days where non-zero was true)...
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/expressions.html http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csspec/html/vclrfcsharpspec_7_2_1.asp http://www.zenspider.com/Languages/Ruby/QuickRef.html#21
For example I hate having to write this in Java:
I think of bitwise and, or, and xor like math operators:
This is what I am thinking for Fan operator precedence (basically Ruby precedence):
It is the same as C/Java/C# except that we move bitwise & | ^ up above relational operators and make | and ^ the same precedence.
Do you guys agree? Doesn't seem like a change that would really bother or trip up hard-code Java or C# programmers.
john Wed 14 Dec 2005
I understand what <=> does, but what is the point of having it? I don't think it's a necessary operator and it doesn't seem like something anyone would ever use. Especially since we have the full set of other comparison operators.
brian Wed 14 Dec 2005
I guess it really isn't needed. But it is trivial to implement, and seems like it should be present since it the "master operator" for all comparisions.
I vote to keep it, although if you and Andy are against it, I wouldn't be upset about axing it.