Evaluation order of index expressions

Daniel Murphy via Digitalmars-d digitalmars-d at puremagic.com
Mon May 25 13:30:43 PDT 2015


"Timon Gehr"  wrote in message news:mjvvq2$19hd$1 at digitalmars.com...

> > As operator overloading is defined in terms of lowering to function
> > calls, I think it's reasonable to decide the order of evaluation after
> > the lowering. This will still be consistent across compilers and
> > platforms.
>
> But almost entirely arbitrary.

Yes.  I don't think this is particularly important, as depending on 
evaluation order is highly discouraged.

> > Preserving the original order would require added complexity
> > that I don't think is warranted.
>
> The compiler would just need to introduce some temporary variables for the 
> two lowerings. Why wouldn't this be warranted to make overloaded operators 
> consistent with built-in ones? If anything, I think it is desirable to 
> have opBinary(B) on type A and opBinaryRight(A) on type B interchangeable.
>
> What complexity are you worried about?

Introducing temporary variables is added complexity.  It affects all sorts 
of other parts of the compiler. 



More information about the Digitalmars-d mailing list