LWN.net Logo

RE: nullable pointers

RE: nullable pointers

Posted Mar 31, 2011 11:00 UTC (Thu) by neilbrown (subscriber, #359)
In reply to: RE: nullable pointers by wahern
Parent article: GCC 4.6.0 released

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.


(Log in to post comments)

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds