My Kingdom For ...

Steven Schveighoffer schveiguy at yahoo.com
Thu Feb 21 11:10:37 PST 2008


"Janice Caron" wrote
> On 21/02/2008, Steven Schveighoffer wrote:
>> Please please please, can we have this either not compile, or else do a
>>  reference compare:
>>
>>  class C {}
>>
>>  C x = null;
>>  x != null;
>>  x == null;
>
> Yeah, but then how would you call opEquals?

Simple.  If you are not doing == null, then call opEquals.  And I don't mean 
make the check at runtime, I mean the compiler should check if you are doing 
== null with the keyword null, then either throw an error or do the bit 
compare.  Anything else, call opEquals.  It's one of those little hackish 
exceptions to the rule that would make life soo much easier, and would not 
impact anyone adversely.

-Steve 





More information about the Digitalmars-d mailing list