D and expression evaluation order.

Daniel Keep daniel.keep.lists at gmail.com
Sun May 6 06:40:51 PDT 2007


Bruno Medeiros wrote:
> Hum, good point. This looks like an unprecedented case, I don't know if
> any other languages have reverse operator overloading like D.

Rubbish.  Python does as well, and for precisely the same reason I
suspect D does: non-commutative operations, and working with existing,
closed types.  For instance, if you have a pre-existing, closed vector
class, and you want to write a matrix class that works with it, you need
to overload both opMul and opMul_r, or it won't work.  I'd argue that
any language that *doesn't* let you write the reverse operation is doing
a pretty half-arsed job of operator overloading...

Hell, I wrote vector and matrix structs from scratch, and I did it that
way since having two templates depend on each other causes MORE than
enough problems... I'm not entirely sure I fixed the data corruption
issue it was causing, and I'd really rather not wrangle with that again.

	-- Daniel

-- 
int getRandomNumber()
{
    return 4; // chosen by fair dice roll.
              // guaranteed to be random.
}

http://xkcd.com/

v2sw5+8Yhw5ln4+5pr6OFPma8u6+7Lw4Tm6+7l6+7D
i28a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP  http://hackerkey.com/



More information about the Digitalmars-d mailing list