Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.lang.c Subject: Re: the nil pointer is not zero Message-ID: <529@taumet.com> Date: 24 Nov 90 05:27:31 GMT References: <27636@mimsy.umd.edu> <164@nazgul.UUCP> <14516@smoke.brl.mil> <171@nazgul.UUCP> Organization: Taumetric Corporation, San Diego Lines: 23 bright@nazgul.UUCP (Walter Bright) writes: >In article <14516@smoke.brl.mil> gwyn@smoke.brl.mil (Doug Gwyn) writes: >/I don't think so. What good would it do you to know how a null pointer >/is represented? There is nothing useful you can do about that. >1. Explanations of how C works become much simpler (note the endless debate > on usenet about NULL and 0). I have to disagree with Walter here. Consider Pascal as a counter- example. A pointer either points to a particular object, or it has the value nil; 'nil' is a keyword. A nil pointer points nowhere. It is always an error to dereference a nil pointer, always caught at run time (in a standard-conforming Pascal system). What could be simpler than that? The confusion in C stems not from nil pointers which might not be zero, but from using a literal zero to represent nil pointers. This leads to the 'obvious' conclusion that a nil pointer must point at address zero and be represented by all-bits-zero. The obvious conclusion is unfortunately not always correct. -- Steve Clamage, TauMetric Corp, steve@taumet.com