Evaluation order
Walter Bright
newshound1 at digitalmars.com
Wed Feb 24 17:24:59 PST 2010
bearophile wrote:
> Walter Bright:
>> All compiler behavior is based on what the observer sees. If the
>> compiler can rearrange things in a manner that the observer cannot
>> detect, then the rearrangement is allowed.
>
> OK. But if the language turns putting impure expressions inside a
> function call into a compile time error, allowing only pure
> expressions inside function calls, then the compiler can always be
> free to rearrange those expressions, and there's both no performance
> penalty and the programmer can be certain there is no performance
> penalty. I guess you are not interested in this idea.
I agree I'm not interested in making impure expressions illegal.
But I was just pointing out that the compiler optimizer *already* relies
on knowing about side effects when reordering code. It's central to any
flow analysis optimization.
More information about the Digitalmars-d
mailing list