Field assignments are reordered in record creations
Thu May 25 04:39:55 CEST 2006
David, thanks a lot fot this great explanation.
I expected the Erlang compiler to behave like a C compiler, and
to execute subexpressions with possible side-effects in the same
order as they are written...
> > So what is ,? Can I not depend on an expression prior to a
> > , being evaluated before something after the ,? What about ;
> > in guard statements? Is it the same idea, simply not called
> > a sequence point? Or is the idea not existent?
Yes, it is. In:
the two function calls are executed in the order in which they
are written, because "," in that case separates two expressions
and evaluates them in order.
Cf. section 6.5 in the ref cited by David Hopwood
"The order in which the subexpressions of an expression are
evaluated is not defined, with one exception:
In a body, the expressions are evaluated strictly from left to
So, using "," to separate expressions seems to be the only way to
have deterministic behaviour in Erlang.
More information about the erlang-questions