Null references redux

Christopher Wright dhasenan at gmail.com
Sat Sep 26 22:13:43 PDT 2009


Jeremie Pelletier wrote:
> What if using 'Object obj;' raises a warning "unitialized variable" and 
> makes everyone wanting non-null references happy, and 'Object obj = 
> null;' raises no warning and makes everyone wanting to keep the current 
> system (all two of us!) happy.
> 
> I believe it's a fair compromise.

It's a large improvement, but only for local variables. If your segfault 
has to do with a local variable, unless your function is monstrously 
large, it should be easy to fix, without changing the type system.

The larger use case is when you have an aggregate member that cannot be 
null. This can be solved via contracts, but they are tedious to write 
and ubiquitous.



More information about the Digitalmars-d mailing list