Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site mulga.SUN
Path: utzoo!watmath!clyde!floyd!harpo!decvax!mulga!kre
From: kre@mulga.SUN (Robert Elz)
Newsgroups: net.unix-wizards
Subject: Re:  Please use NULL instead of 0 whenever you have a pointer!
Message-ID: <200@mulga.SUN>
Date: Sun, 5-Feb-84 01:29:02 EST
Article-I.D.: mulga.200
Posted: Sun Feb  5 01:29:02 1984
Date-Received: Thu, 9-Feb-84 07:39:25 EST
References: <16022@sri-arpa.UUCP>, <3811@genrad.UUCP>
Organization: Comp Sci, Melbourne Uni, Australia
Lines: 23

If defining a new "magic object" (NIL) would solve the problem
at all, I'm sure that would have been done.

However, the constant '0' already is that magic object, as far
as the current syntax and semantics of C allow there to be one at all.

The compiler cannot pass the "correct" type of null pointer to
a function as an arg, unless (in the arg list) you tell it what
the correct type is, as otherwise it has no knowledge of what that
would be.  It is no good at all to pass the "widest" null pointer,
the only one that will do is the one that's just the right width.
(Given a wider pointer, of known type, its always possible to convert
it to another, narrower, pointer, but something has to do that
conversion.  Just dumping a wide pointer on the stack and hoping that
its going to mean the right thing in a called function simply won't work).

Should C be altered so that the compiler is able to determine what
the right type of an arg is at a function call (ie: forward declararions)
then '0' will serve the purpose of the "magic object" quite well
enough, as it does in assignments to pointers, and comparisons.

Robert Elz
decvax!mulga!kre