On Saturday, September 15, 2012 19:57:03 Henning Pohl wrote: > 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.htm > l
I'd argue that using null for indicating something other than the lack of a value is bad design. But there are plenty of cases where being able to indicate that there is no value is useful. And if a function requires that a pointer or reference or array or whatever have a value, then there's always DbC or exceptions. Just because someone can misuse a feature doesn't mean that a feature shouldn't be there. - Jonathan M Davis
