Path: utzoo!mnetor!uunet!pwcmrd!skipnyc!atpal!tneff From: tneff@atpal.UUCP (Tom Neff) Newsgroups: comp.lang.c Subject: Re: C Style (Was Re: == vs =) Message-ID: <126@atpal.UUCP> Date: 13 Apr 88 16:32:26 GMT References: <11216@brl-adm.ARPA> <2111@chinet.UUCP> <4403@garfield.UUCP> <226@hotlr.ATT> <130@obie.UUCP> <5981@utcsri.UUCP> <1982@ubc-cs.UUCP> Reply-To: tneff@atpal.UUCP (Tom Neff) Organization: Rational Technologies, Inc. Lines: 19 Summary: You said it right In article <1982@ubc-cs.UUCP> pajari@grads.cs.ubc.ca (George Pajari) writes: >In article <130@obie.UUCP> wes@obie.UUCP (Barnacle Wes) writes: >> if (status = *statreg) { > >What is wrong with: > > if ((status = *statreg) != NULL)... For what it's worth, the latter is the preferred formulation as recommended by Harbison&Steele (2nd ed.) and Gimpel's PC-LINT, among others. Certain grizzled veterans may crave the older, less wordy, more "clever" formulation, but the explicit comparison is easier to read and less likely to be confused for something else. If you get into the habit of never writing if(variable), you don't tend to have =/== accidents, in my experience. Also, both MSC and PC-LINT are nice and flag the former usage above as being possibly a typo. -- Tom Neff