References in D

Jonathan M Davis jmdavisProg at gmx.com
Thu Oct 4 21:38:12 PDT 2012


On Friday, October 05, 2012 05:42:03 Alex Burton wrote:
> I realise what is currently the case I am making an argument as
> to why I this should be changed (at least for class references in
> D).

This was talking about C++ references, not D, giving an example of how they 
can be null even though most people think that they can't be. int& isn't even 
legal syntax in D. So, you're responding to the wrong post if you want to talk 
about D references. There are plenty of other places in this thread where such 
a response would make sense, but not here.

Regardless, references in D will _never_ be non-nullable. It would break too 
much code to change it now regardless of whether nullable or non-nullable is 
better. At most, you'll get non-nullable references in addition to nullable 
ones at some point in the future, but that's not going to happen anytime soon. 
The solution that has been decided on is to add a wrapper struct to Phobos 
which allows you to treat a reference as non-nullable. It's far too late to 
change how D works with something so core to the language.

- Jonathan M Davis


More information about the Digitalmars-d mailing list