There is a general lack of understanding of how operators work. Honestly, every statement is syntactic sugar.
All you have to do is understand what is actually happening for each operator. Assume the following:
a = b -> Operators.set(a, b)
Complex operators can then be rewritten using these generalizations (please ignore return types for simplicity):
Operators.addTo(a, b) {
You can rewrite your example:
int a = 3; a = (a++) * (a++);
but
Operators.set(a, 3) Operators.set(a, Operators.multiply(Operators.postIncrement(a), Operators.postIncrement(a)));
What can be divided using several variables:
Operators.set(a, 3) Operators.set(b, Operators.postIncrement(a)) Operators.set(c, Operators.postIncrement(a)) Operators.set(a, Operators.multiply(b, c))
This, of course, in more detail, but it immediately becomes obvious that you never want to perform more than two operations on the same line.
zzzzBov Nov 07 '11 at 19:05 2011-11-07 19:05
source share