Re:Many programming languages have infix expressions, but ge...
by pmjordan on Sunday January 31, 2010 @07:04PM
(#1091390)
Java throws exceptions on overflow (and underflow), which presumably interferes with that, e.g.:
Depending on order of evaluation, this either throws an overflow exception or assigns the number 3 billion to D. There is a hard rule in the spec that defines what must happen here. In C or C++ there are no such exceptions, so the compiler can (and does) transform arithmetic expressions where it's advantageous. (this is obviously a trivial example which will compile down to a constant anyway)
[ Parent
| on HN ]
Re:Many programming languages have infix expressions, but ge...
by prodigal_erik on Sunday January 31, 2010 @07:17PM
(#1091408)
But http://java.sun.com/docs/books/jls/second_edition/html/types... says
> The built-in integer operators do not indicate overflow or underflow in any way. The only numeric operators that can throw an exception are the integer divide operator / and the integer remainder operator %, which throw an ArithmeticException if the right-hand operand is zero.
Maybe it's true that subexpressions can't be reordered for other reasons, but offhand I can't find that restriction.