Stride

Artur Skawina art.08.09 at gmail.com
Mon Feb 13 12:49:05 PST 2012


On 02/13/12 20:47, Jonathan M Davis wrote:
> On Monday, February 13, 2012 19:47:03 Artur Skawina wrote:
>> On 02/13/12 18:57, Jonathan M Davis wrote:
>>> On Sunday, February 12, 2012 10:07:52 Ali Çehreli wrote:
>>>> Related question: Does D define the order of evaluation in an
>>>> expression
>>>> like
>>>>
>>>> foo() ~ bar()
>>>>
>>>> Or is it unspecified as in C and C++?
>>>
>>> It's currently unspecified. Walter has stated that he wants to make it
>>> so that it's always left to right, but I don't believe that he's done
>>> it yet, and it may or may not ever happen.
>>
>> Actually, it *is* specified as left-to-right, except for assignments and
>> argument evaluation. http://dlang.org/expression.html
>> No idea if the compiler fully implements that part of the spec.
> 
> Well, foo() ~ bar() _is_ argument evaluation if you're dealing with an 
> overloaded operator. And unfortunately, whether the spec is what the compiler 
> does is frequently suspect anyway. So, who knows.

"argument evaluation" in this context means that given eg "f(a,b,c);"
it's not specified in what order the expressions 'a', 'b', and 'c'
are evaluated, which matters if they are dependent or have side
effects. (depending on arg passing conventions it can make sense to 
implement this one way or the other). If an expression is specced
as l-t-r (as CatExpression is here) then the call to foo() must
happen before executing bar(); the operator only comes into play later.

artur


More information about the Digitalmars-d-learn mailing list