Expression evaluation order

Timon Gehr timon.gehr at gmx.ch
Sat Jun 15 10:44:42 PDT 2013


On 06/15/2013 04:21 AM, Jonathan M Davis wrote:
> On Saturday, June 15, 2013 01:46:49 Timon Gehr wrote:
>> On 06/14/2013 02:13 AM, Jonathan M Davis wrote:
>>> ...
>>> Personally, I would expect it to fully evaluate the right-hand side of an
>>> assignment expression before evaluating anything on the left, and I'd
>>> expect the same of any operator which is right-associative, ...
>>
>> Why? Associativity is unrelated to evaluation order.
>
> It seems natural to me that the stuff on the associated side would be evaluated
> before the stuff on the other, but that doesn't mean that it's the best way to
> go. It's just what I would have expected. So, if there's a good reason to do
> it differently, then I don't necessarily have a problem with that.
>
> - Jonathan M Davis
>

Well, I can't think of a _good_ reason now. :)

Since Walter once stated that evaluation is supposed to be LTR, this is 
what I have implemented for CTFE. The stack-based bytecode interpreter 
already relies on having the address-related information pushed before 
the value, and changing the evaluation order would therefore imply a 
little work.


More information about the Digitalmars-d mailing list