M
mdh
May I ask a question related to one I just posted. I am doing external
variables in K&R. As an example, the construction of an RPN calculator
is considered. One of the executions involves finding the difference
between 2 "popped" values from a stack. It is noted that the following
code is incorrect, as the order "in which the two calls of pop are
evaluated is not defined"
namely:
push(pop()-pop());
Could anyone elaborate on this for me? What exactly is meant by this,
and why? Surely if I pop a value from an array, say at position 'x' and
then pop the next value at '(x-1)' and then perform an execution of
x-(x-1), why would this not perform as expected? Or is there something
a lot more subtle that I am missing.
Thank you all as always.
variables in K&R. As an example, the construction of an RPN calculator
is considered. One of the executions involves finding the difference
between 2 "popped" values from a stack. It is noted that the following
code is incorrect, as the order "in which the two calls of pop are
evaluated is not defined"
namely:
push(pop()-pop());
Could anyone elaborate on this for me? What exactly is meant by this,
and why? Surely if I pop a value from an array, say at position 'x' and
then pop the next value at '(x-1)' and then perform an execution of
x-(x-1), why would this not perform as expected? Or is there something
a lot more subtle that I am missing.
Thank you all as always.