My Kingdom For ...
Bill Baxter
dnewsgroup at billbaxter.com
Thu Feb 21 11:44:55 PST 2008
Steven Schveighoffer wrote:
> "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.
I'd vote enthusiastically for issuing a warning, but I don't like the
idea of changing behavior just for that one special case.
For instance what would this do?
C Null = null;
if (x != Null) {...}
Seems pretty confusing to me if that does something different from x!=null.
--bb
More information about the Digitalmars-d
mailing list