On Sat, 15 Sep 2012 20:06:01 +0200, Jonathan M Davis <jmdavisp...@gmx.com>
wrote:
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.
The want for non-nullable pointers and references does not mean nullable
ones should go - far from it. But using nullable pointers where only non-
null values are meaningful is like a function taking a float and working
only when the value is an integer. We're not saying floats are bad,
we're saying 'if your function only works with integers, then use an int'.
--
Simen