Please use NULL instead of 0 whenever you have a pointer!

John Nelson john at genrad.UUCP
Thu Feb 2 01:31:28 AEST 1984


After hearing all the controversy that NULL is identically equal to zero,
the only sane solution is to fix the C language.  Add a special constant
that is the equivalent of zero, but is a pointer.  Since NULL already has
bad connotations, let's borrow from PASCAL, and call it NIL.

Now NIL is guaranteed to be a pointer of the largest type (char * ?) but
it will compare against any pointer without error and it can be passed
as a subroutine argument.  NIL can be assigned to any pointer type, and
will always be guaranteed to be different than a valid pointer.

It would be nice if the definition of NIL included the restriction that
a dereference of NIL would always cause a run-time error, but maybe this
is too much to ask for.

Those of us without the "fixed" compiler can #define NIL ((char *) 0)
and use it anyway (although some of the compilers may complain about
"illegal pointer combination"s)



More information about the Comp.unix.wizards mailing list