templating opEquals/opCmp (e.g. for DSL/expression templates)

Nicholas Wilson iamthewilsonator at hotmail.com
Wed Feb 13 02:49:21 UTC 2019


On Wednesday, 13 February 2019 at 02:37:50 UTC, H. S. Teoh wrote:
> On Wed, Feb 13, 2019 at 01:24:45AM +0000, Rubn via 
> Digitalmars-d wrote: [...]
>> Then you have things like "min" where you can do:
>> 
>>     foo( a /min/ b );
>> 
>> To get the "min" value between a and b. I guess you could use 
>> this as an example of why not to allow.
>
> Yes, that's a fine example of operator overloading abuse.
>
>
>> But at the same time, we're already pretty much there. That 
>> includes "==" operator in that. So the comparisons operators 
>> aren't even consistent.
> [...]
>
> Don't get me wrong, the situation in D isn't perfect, but 
> imperfection shouldn't be a reason to open the door to worse 
> things.

Imperfection should be a reason for adding things to make it 
better. That they can be abused and nobody does because that 
would be a stupid thing to do is of no relevance and certainly 
not a reason to not do it.




More information about the Digitalmars-d mailing list