Some problems with operator overloading

Trass3r un at known.com
Mon Mar 15 06:53:48 PDT 2010


>> But that can cause bugs: it's easy for programmers to forget to use  
>> opEquals instead of opBinary("==").
>
> Again, opBinary and opEquals are simply functions.  There is nothing  
> special about their existence, just about how the compiler rewrites the  
> operators into calling those functions.  The fact that opBinary does not  
> get called is the same as defining a function that does not get called.   
> These kinds of errors are appropriate for a lint tool.
>

Seconded.
The language specification is clear about that. == is not to be used with  
opBinary.



More information about the Digitalmars-d mailing list