Path: utzoo!attcan!uunet!cs.utexas.edu!usc!gem.mps.ohio-state.edu!apple!sun-barr!ames!ncar!ico!ism780c!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: Abandon NULL for (0) Message-ID: <14678@haddock.ima.isc.com> Date: 22 Sep 89 15:42:26 GMT References: <6502@ux.cs.man.ac.uk> <14718@bfmny0.UU.NET> <146@bbxsda.UUCP> <17505@pasteur.Berkeley.EDU> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Cambridge, MA 02138-5302 Lines: 23 Some people have been raising the strawman that "(0)" is inferior to "NULL" because of an implicit cast which they believe to be attached to the latter. This is not true. In C, *any* use of "NULL" in a portable context (namely, anyplace where a null pointer constant of some type was intended, except for an uncasted argument to a function not covered by a prototype%) may be safely replaced with "(0)". Hence, this is no reason to avoid using "(0)". Despite which, there *are* good reasons for not doing it. The word "NULL" has been conventionally used for decades to represent a null pointer constant; when I see it, I know that it's a pointer context. The original poster seemed to be recommending the use of redundant parens around the zero to convey this same information, which would be okay except that it's not an established convention already. People will look at it and scratch their heads. In particular, if I were maintaining that code, I'd change the "(0)"'s back to "NULL"'s as fast as I found them. And if NULL were misimplemented on that implementation, I'd simply fix that problem, rather than pollute my own code with a workaround. Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint ________ % In which case neither "NULL" nor "0" is portable; you need a cast.