Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!bionet!sdsu!usc!elroy.jpl.nasa.gov!cit-vax!wen-king From: wen-king@cit-vax.Caltech.Edu (King Su) Newsgroups: comp.lang.c Subject: Re: comma operator Message-ID: <11445@cit-vax.Caltech.Edu> Date: 2 Aug 89 03:36:55 GMT References: <10099@mpx2.mpx.com> <93@microsoft.UUCP> <10100@mpx2.mpx.com> <10562@smoke.BRL.MIL> <1989Jul24.194646.3012@nc386.uucp> <5630@pt.cs.cmu.edu> <1989Jul28.174033.12734@jarvis.csri.toronto.edu> <3553@buengc.BU.EDU> Reply-To: wen-king@cit-vax.UUCP (Wen-King Su) Organization: California Institute of Technology Lines: 29 In article <3553@buengc.BU.EDU> bph@buengc.bu.edu (Blair P. Houghton) writes: >In article <1989Jul28.174033.12734@jarvis.csri.toronto.edu> flaps@dgp.toronto.edu (Alan J Rosenthal) writes: <> >>dandb@k.gp.cs.cmu.edu (Dean Rubine) writes: <>>I also occasionally use the comma to save braces: >>> if((f = fopen(file, "r")) == NULL) <>> fprintf(stderr, "Can't open %s\n", file), exit(2); >> <>Funny, I use braces to save commas: >> if ((f = fopen(file, "r")) == NULL) { <> fprintf(stderr, "Can't open %s\n", file); >> exit(2); <> } > as the comma's operand, which may only be an expression... Funny, you didn't notice that both fprintf(...) and exit(...) are expressions. My rule about style is that there is no rule. You can use NULL, TRUE, comma, or even goto, as long as the end product is easier to understand as a result of their use. You can even change your style from time to time, if it helps. -- /*------------------------------------------------------------------------*\ | Wen-King Su wen-king@vlsi.caltech.edu Caltech Corp of Cosmic Engineers | \*------------------------------------------------------------------------*/