Take the following C code (K & R p. 77):
push(pop() - pop()); /* WRONG */
The book says that since - and / are not commutative operators, the order in which 2 pop functions are evaluated (obviously, to get the correct result) is needed ... and therefore, you first have to put the result of the first function in a variable, and then go to arithmetic, for example:
op2 = pop(); push(op2 - pop());
This is apparently due to the fact that the compiler cannot guarantee in which order the functions are evaluated (... why?)
My question is, does C # do the same? as in, do I need to worry about this while working with C #? and, for that matter, any of the other higher-level languages?
c math c #
Andreas Grech
source share