Field assignments are reordered in record creations

David Hopwood <>
Wed May 24 15:42:22 CEST 2006


 wrote:
> I don't believe what is happen is what you think is happening.  The 
> issue is that the order of execution in a single sequence point is  not
> defined.  Your code does no say anything about which record  fields gets
> assigned first, simply which function gets executed  first.  You cannot
> depend on the order of execution of an expression  to reflect how you
> wrote it.  Compilers are generally free to execute  expressions in
> whatever order is easiest for them.

Erlang is not C; it has no concept of sequence points. However, you're
correct that the evaluation order of arguments to an operator or function
call is undefined. See section 6.3 of
<http://www.it.uu.se/research/group/hipe/cerl/doc/core_erlang-1.0.3.pdf>.

-- 
David Hopwood <>





More information about the erlang-questions mailing list