D and expression evaluation order.
Manfred Nowak
svv1999 at hotmail.com
Fri Apr 27 12:14:22 PDT 2007
Russell Lewis wrote
> Manfred Nowak wrote:
>> Russell Lewis wrote
>>
>>> Why prevent optimizers from doing all that they can conceive of?
>>
>> This is not an issue, because the requirement is to define an
>> order for those cases only, where currently evaluation order
>> matters. In all other cases the compiler is free to choose the
>> optimum the same way it currently does.
>
> I don't understand what you're saying here; perhaps your
> definition was too indirect? What are you wanting to define
> orders for, and what not?
Have a look at one of Brunos examples:
| c = a + (b = c);
There seem to exist some cases where evaluation order matters.
This is because the coder might have believed in evaluating this
expression as the sequence:
b = c;
c = a + b; // c == a + c
or as the sequence:
c = a + b;
b = c; // b == a + c
which might be different, if one of the following conditions holds:
a != 0
b != c
If it can be deduced from the context, that none of this conditions
holds, then there is no need to define an order and thus no need to
"prevent optimizers from doing all that they can conceive of".
OTOH if it can be deduced from the context, that at least one of this
conditions might hold then Brunos requirement kicks in.
> Moreover, if it's not an issue, then why did Walter bring it up?
> Apparently it *is* an issue.
I do not realize that Walter wants to extend Brunos requirement.
-manfred
More information about the Digitalmars-d
mailing list