References in D

Henning Pohl henning at still-hidden.de
Sat Sep 15 10:57:03 PDT 2012


On Saturday, 15 September 2012 at 17:12:23 UTC, Jonathan M Davis 
wrote:
> Of course people use it. Having nullable types is _highly_ 
> useful. It would
> suck if references were non-nullable. That would be _horrible_ 
> IMHO. Having a
> means to have non-nullable references for cases where that 
> makes sense isn't
> necessarily a bad thing, but null is a very useful construct, 
> and I'd _hate_
> to see normal class references be non-nullable.
>
> - Jonathan M Davis

And many usages of null as a state leads to really bad design. 
There are functions which behaviour is completly different if you 
pass null instead of a valid pointer/reference. An example would 
be:

http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetDeviceIDs.html


More information about the Digitalmars-d mailing list