Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site wanginst.UUCP Path: utzoo!linus!wanginst!vishniac From: vishniac@wanginst.UUCP (Ephraim Vishniac) Newsgroups: net.lang.c Subject: Re: Re: if (p), where p is a pointer Message-ID: <1083@wanginst.UUCP> Date: Fri, 13-Sep-85 08:06:20 EDT Article-I.D.: wanginst.1083 Posted: Fri Sep 13 08:06:20 1985 Date-Received: Sat, 14-Sep-85 03:55:53 EDT References: <118@mit-hector.UUCP> <4300@alice.UUCP> Organization: Wang Institute, Tyngsboro, Ma. 01879 Lines: 21 > > With all this talk about NULL pointers not necessarily being equal to 0, > > I'm no longer sure what is and isn't portable code. An C idiom I see > > (and write) frequently is > > *ptr; > > ... > > if (ptr) > > > > Will this work correctly on a machine where NULL is not 0? > > No, you don't need to say NULL explicitly. The relevant rules are: 1. You should only make explicit comparisons in your code *only* where absolutely necessary. Not only does this save at least 1% in editing keystrokes, but it deters nosy people from reading (or, at least, from understanding) your code. The way I see it, portability is not the essential issue here: *clarity* is. -- Ephraim Vishniac [apollo, bbncca, cadmus, decvax, harvard, linus, masscomp]!wanginst!vishniac vishniac%Wang-Inst@Csnet-Relay