Operators overloading in D2 again

Pelle pelle.mansson at gmail.com
Mon May 3 09:32:07 PDT 2010


On 05/03/2010 04:28 PM, Dan wrote:
> Hi,
>
> it certainly helps. However I can't help myself, I still thinking that this is the most complicated, hard read and to understand way to
> overload operators. Maybe there is something I'm missing but I can't really see the reason of all that. Other languages adopts a much
> easier approach, for example python but also C++ that D is trying to surpass (and it does in most cases) when it comes to operator
> overloading is much more clear than D.
>
> I still thinking that the D1's approach was much better than this.

The D way is superior, because you don't need to come up with arbitrary 
names, like the D1/Python way, and it's much easier to parse than the 
C++-way, at least I think it is.

>
> Anyway, now I have another problem: I can't get how to overload operators like these<=,<,>=,>.
> I read the documentation but I can't really understand it.
>

http://digitalmars.com/d/2.0/operatoroverloading.html#compare

You should define an opCmp.

> Thanks for the precious help guys.
>        DAniele



More information about the Digitalmars-d-learn mailing list