Field assignments are reordered in record creations
Thu May 25 05:28:23 CEST 2006
Which sounds like the definition of sequence point...? Please correct
On May 24, 2006, at 10:39 PM, Romain Lenglet wrote:
> 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:
> start() ->
> 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.
> Romain LENGLET
More information about the erlang-questions