D and expression evaluation order.

Daniel Keep daniel.keep.lists at gmail.com
Sun Apr 29 17:37:48 PDT 2007



Bruno Medeiros wrote:
> C# does support operator overload. Dunno about Python and Ruby.
> But I don't see how operator overloading or calling conventions would
> have any effect on having a completely defined expression order of
> evaluation. Indeed, I don't think it makes any difference.

Python:

>>> class FakeInt:
        def __init__(self, v):
            self.v = v
        def __add__(self, rhs):
            return FakeInt(self.v+rhs.v)
        def __str__(self):
            return str(self.v)

>>> FakeInt(2) + FakeInt(3)
5

	-- 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