Null references redux

grauzone none at example.net
Sat Sep 26 15:18:00 PDT 2009


Walter Bright wrote:
> Jarrett Billingsley wrote:
>> It wouldn't. The compiler wouldn't allow it. It would force you to
>> initialize it. That is the entire point of nonnull references.
> 
> Initialize it to what?
> 
> A user-defined default object? What should happen if that default object 
> is accessed? Throw an exception? <g>
> 
> How would you define an "empty" slot in a data structure?

You can allow a non-nullable reference to be null, just like you allow 
an immutable object to be mutable during construction.

You just have to make sure the non-nullable reference is definitely 
assigned.



More information about the Digitalmars-d mailing list