The terms \'operator precedence\' and \'order of evaluation\' are very commonly used terms in programming and extremely important for a programmer to know. And, as far as I
A good way to look at this is to take the expression tree.
If you have an expression, lets say x+y*z
you can rewrite that into an expression tree:
Applying the priority and associativity rules:
x + ( y * z )
After applying the priority and associativity rules, you can safely forget about them.
In tree form:
x
+
y
*
z
Now the leaves of this expression are x
, y
and z
. What this means is that you can evaluate x
, y
and z
in any order you want, and also it means that you can evaluate the result of *
and x
in any order.
Now since these expressions don't have side effects you don't really care. But if they do, the ordering can change the result, and since the ordering can be anything the compiler decides, you have a problem.
Now, sequence points bring a bit of order into this chaos. They effectively cut the tree into sections.
x + y * z, z = 10, x + y * z
after priority and associativity
x + ( y * z ) , z = 10, x + ( y * z)
the tree:
x
+
y
*
z
, ------------
z
=
10
, ------------
x
+
y
*
z
The top part of the tree will be evaluated before the middle, and middle before bottom.