What's the status of old-style operator overloads in D2?

Daniel Murphy via Digitalmars-d digitalmars-d at puremagic.com
Tue Apr 22 08:50:21 PDT 2014


"Andrej Mitrovic"  wrote in message 
news:ifghzjafvfqrqkhlpinc at forum.dlang.org...

> Old-style operator overloads (such as opCom, opAnd, etc) have largely been 
> superseded by new-style templated operator overloads (opUnary, opBinary, 
> etc).

I prefer the old ones mainly because the names are better and the code 
easier to read.  When you are implementing one operator per function (ie 
most of the time) the extra template syntax is just unnecessary noise.

T opMul(T other)

vs

T opBinary(string op : "*")(T other)

The old names were chosen to match what the operations were supposed to be, 
not for the syntax.  In that regard the new syntax is a step backwards. 



More information about the Digitalmars-d mailing list