Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!inuxc!iuvax!pur-ee!uiucdcs!uxc.cso.uiuc.edu!ccvaxa!preece From: preece@ccvaxa.UUCP Newsgroups: comp.lang.c Subject: Re: Writing readable code Message-ID: <28700014@ccvaxa> Date: Mon, 6-Jul-87 10:42:00 EDT Article-I.D.: ccvaxa.28700014 Posted: Mon Jul 6 10:42:00 1987 Date-Received: Sat, 11-Jul-87 10:46:22 EDT References: <7220@mimsy.UUCP> Lines: 30 Nf-ID: #R:mimsy.UUCP:7220:ccvaxa:28700014:000:1247 Nf-From: ccvaxa.UUCP!preece Jul 6 09:42:00 1987 stevesu@copper.TEK.COM: > It has been pointed out that my original posting had a blatant > error in it: (!p) and (p != NULL) are not at all equivalent, but > in fact are exactly opposite. I was at first acutely embarrassed, > but I am now flatly amazed that the statements have been argued > so hotly, by some of the best minds on the network, without > noting this crucial fact. ---------- Actually, when I wrote my response to the original note I did notice and correct the error in my own text; I didn't comment on the error, though I chuckled. Why, though, does the presence of the error and your own failure to notice it imply to you that one form or the other is preferable? All it says to me is that MIXING the two forms is dangerous. While we have, here, house coding standards, the bottom line is "Make it fit in with the surrounding code." If you are maintaining a program written in "if (!p)" style, PLEASE, PLEASE don't decide that you want to use the "right" "if (p == NULL)" form in your code; likewise don't use "if (!p)" if the rest of the program uses "if (p == NULL)". Consistency within a program is the most important thing. -- scott preece gould/csd - urbana uucp: ihnp4!uiucdcs!ccvaxa!preece arpa: preece@Gould.com