In those circumstances you don't need a generic null reference, you just need a sentinel, which can be typed. A null reference is a conflation of several distinct notions. e.g., in poor layman's terms, uninitialized, missing, nothing-to-see-here, not-in-set, etc. A computational statistics professor once tried to explain to me the formal distinctions (including a new one he was proposing), but at the time I didn't grasp the importance and subtlety; all I remember now--a decade later--is that I wish I paid better attention.
I'm not exactly sure what is gained from removing generic null references entirely, though.
Posted Mar 31, 2011 11:00 UTC (Thu) by neilbrown (subscriber, #359)
[Link]
This reminds me of an observation I read many years ago that a two-valued type could mean any one of true/false, on/off, yes/no, success/fail and many other more domain-specific alternatives.
Grouping them all under "Boolean" is thus confusing.
However this is no worse than the fact that '2' could mean inches or centimetres ... or kilograms or people or almost anything.
It is for this reason that Ada (and possibly other languages) allows "new integer" which defines a new type that behaves like integer but is not type-compatible with any other integer type. It is a concept that does have its place, but the extra book-keeping would probably drive most programmers crazy - even static typing seems to be out of favour with a lot of people these days (python? Perl?) and this extra type differentiation is like static typing on steroids.
You are correct of course that a generic NULL reference is not needed, but I fail to see that a typed NULL actually buys you anything at all...
I certainly agree that it is not clear what could be gained by removing generic null references.