Take the following C code (K&R pg. 77) :
push(pop() - pop()); /* WRONG */
The book says that since -
and /
are not commutative operators, the order in which the 2 pop
functions are evaluated is necessary (obviously, to get the correct result)...and thus you have to put the result of the first function in a variable first and then proceed with the arithmetic, like such:
op2 = pop();
push(op2 - pop());
Apparently this is because the compiler can't guarantee in which order the functions are evaluated (...why?)
My question is, does C# do this same thing? as in, do I have to worry about this sort of thing when working with C# ? and for that matter, any of the other higher level languages ?