Path: utzoo!mnetor!uunet!ncc!alberta!ubc-cs!grads.cs.ubc.ca!pajari From: pajari@grads.cs.ubc.ca (George Pajari) Newsgroups: comp.lang.c Subject: C Style (Was Re: == vs =) Message-ID: <1982@ubc-cs.UUCP> Date: 12 Apr 88 07:55:18 GMT References: <11216@brl-adm.ARPA> <2111@chinet.UUCP> <4403@garfield.UUCP> <226@hotlr.ATT> <130@obie.UUCP> <5981@utcsri.UUCP> Sender: nobody@ubc-cs.UUCP Reply-To: pajari@grads.cs.ubc.ca (George Pajari) Organization: UBC Department of Computer Science, Vancouver, B.C., Canada Lines: 19 In article <130@obie.UUCP> wes@obie.UUCP (Barnacle Wes) writes: >... `=' is NOT always invalid in an if clause: > > if (status = *statreg) { Article <5981@utcsri.UUCP> by flaps@utcsri.UUCP (Alan J Rosenthal) > ... better written as "if ((status = *statreg))" > some people even recommend "if ((status = *statreg), status)" What is wrong with: if ((status = *statreg) != NULL)... Most compilers I've tried generate the same code as for the original and this version (I claim) is the most readble (i.e. scanned quickly by a human with the fewest resulting semantic errors) of the three. George Pajari