Field assignments are reordered in record creations

orbitz@REDACTED orbitz@REDACTED
Fri May 26 01:19:32 CEST 2006


I'm not sure I follow your statements about C.  C has sequence  
points, they are && || ; , ?:
I'm not sure I understand what you mean about reading/writing bytes  
and etc have to do with ordering?  And what does partial ordering mean?


On May 25, 2006, at 12:24 AM, David Hopwood wrote:

> 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...
>
> I think you might have misunderstood my explanation. In *both* C
> and Erlang, the order of evaluation of procedure arguments is
> unspecified (because the spec for each language explicitly says so).
>
> In Erlang, that's the whole story. All you need to know is that ','
> specifies left-to-right evaluation, and other operators don't.
> No concept of sequence points is needed or useful.
>
>
> In C, it's a whole lot more complicated. In fact I'm pretty sure
> that most C programmers don't understand how much more complicated.
> There is a partial ordering of "events", where an event is one of:
>
>  - reading the value of a byte,
>  - writing a value to a byte,
>  - designation of a byte in an object,
>  - a function call,
>  - a sequence point
>
> and each subexpression constrains the ordering. Then there are rules
> about which sets of possible orderings cause undefined and/or  
> unspecified
> behaviour, which are sufficiently vague that comp.std.c can have  
> several-
> month-long flamewars about how they should be interpreted.
>
> So, it's probably not a good idea to try to understand other  
> languages'
> evaluation orders in terms of concepts from C. Most other languages  
> are
> much simpler.
>
> -- 
> David Hopwood <david.nospam.hopwood@REDACTED>
>
>




More information about the erlang-questions mailing list