My Kingdom For ...

Steven Schveighoffer schveiguy at yahoo.com
Thu Feb 21 09:45:29 PST 2008


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;

I just got bit by this again today!  I hate this stupid "feature".  The 
result is always a segmentation fault, with no information on where it 
happened.  I probably have more of these in my code that just haven't 
executed yet.

Before people respond saying "you need to use is or !is", um yeah I know.  I 
just can't get my brain to re-learn how to compare to null, when every other 
language on the planet does it with ==.  Even if the compiler complained, I 
wouldn't mind.

If ever there was a subtle bug that could easily be fixed by a compiler 
update, and absolutely wouldn't affect any existing valid code, this is it.

-Steve 





More information about the Digitalmars-d mailing list