*References cannot be null, whereas pointers can; every reference refers to some object, although it may or may not be valid. Note that for this reason, containers of references are not allowed.

* References cannot be uninitialized. Because it is impossible to reinitialize a reference, they must be initialized as soon as they are created. In particular, local and global variables must be initialized where they are defined, and references which are data members of class instances must be initialized in the initializer list of the class's constructor. For example: int& k; // compiler will complain: error: `k' declared as reference but not initialized

That would be a dream: not null references. I'm still think that D needs something like that. And I'm not talking about of some struct constructs like NotNullable, which will be added in std.typecons later. I'm talking about built-in support.

Reply via email to