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: What C compilers have non-zero null pointers? Message-ID: <321@taumet.com> Date: 18 Jul 90 15:52:27 GMT References: <9007161750.AA00664@edison.CHO.GE.COM> <12288@netcom.UUCP> Organization: Taumetric Corporation, San Diego Lines: 26 ergo@netcom.UUCP (Isaac Rabinovitch) writes: >But what the "NULL should always be 0" diehards want is not to >write (for example) > for (ptr = fist; ptr != 0; ptr = ptr->next) >in which 0 should probably be #DEFINED anyway, but rather > for (ptr = first; ptr ; ptr = ptr->next) >which produces tighter code ... If in this context the expression ptr produces code which is better than ptr != 0 then you are the victim of a lazy compiler writer. There should be no difference, since 'ptr' is shorthand for 'ptr != 0'. I would complain to the vendor, or buy a better compiler. This is the sort of micro-optimization that programmers in a higher level language should NOT have to worry about. On compiler A, one code version may produce a more efficient program; on compiler B, the reverse may be true. Compiler B might even be the next release of compiler A. Thus, the effort spent in this micro-optimization is not only wastful, but may be counter-productive over time. -- Steve Clamage, TauMetric Corp, steve@taumet.com