Operators overloading

Jonathan M Davis jmdavisProg at gmx.com
Sun May 19 03:58:52 PDT 2013


On Sunday, May 19, 2013 12:41:52 Idan Arye wrote:
> At any rate, I'm not sure how useful it would be. Operator
> overloading code usually fit for a single operator - you usually
> write one for each operator:

Actually, it's usually considered good practice to use the same function for 
several operators and mixin the operator. In most cases, with arithmetic 
operators, that allows you to use one function for several operators and is 
the main reason why overloaded operators now use strings like they do rather 
than being opAdd, opSub, etc. like they used to be. Sometimes, it _is_ 
necessary to have an overload per operator, but usually that can be avoided.

- Jonathan M Davis


More information about the Digitalmars-d mailing list