Null references (oh no, not again!)

Georg Wrede georg.wrede at iki.fi
Fri Mar 6 04:38:20 PST 2009


Nick Sabalausky wrote:
> "Kagamin" <spam at here.lot> wrote in message 
>> I doubt that blunt non-null forcing will solve this problem. If you're 
>> forced to use non-null, you'll invent a means to fool the compiler, some 
>> analogue of null reference - a stub object, which use will result into the 
>> same bug, with the difference that application won't crash immediately, 
>> but will behave in unpredictable way, at some point causing some other 
>> exception, so eventually you'll get your crash. Profit will be 
>> infinitesimal if any.
> 
> The idea is that non-null would not be forced, but rather be the default 
> with an optional nullable for the times when it really is needed. 


This is interesting. I wonder what the practical result of non-null as 
default will be. Do programmers bother to specify nullable when needed, 
or will they "try to do the [perceived] Right Thing" by assigning stupid 
default values?

If the latter happens, then we really are worse off than with nulls.

Then searching for the elusive bug will be much more work.



More information about the Digitalmars-d mailing list