Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!sharkey!atanasoff!hascall From: hascall@atanasoff.cs.iastate.edu (John Hascall) Newsgroups: comp.lang.c Subject: Re: comma operator Message-ID: <1296@atanasoff.cs.iastate.edu> Date: 4 Aug 89 18:28:48 GMT References: <10099@mpx2.mpx.com> <93@microsoft.UUCP> <10100@mpx2.mpx.com> <918@helios.toronto.edu> <13074@megaron.arizona.edu> <9736@alice.UUCP> Reply-To: hascall@atanasoff.cs.iastate.edu.UUCP (John Hascall) Organization: Iowa State Univ. Computation Center Lines: 36 In article <9736> debra@alice.UUCP () writes: }In article <13074> robert@arizona.edu (Robert J. Drabek) writes: [... comma stuff ...] }The following is also a problem: }if i have something like } if (e) } return; }and want to get some debug output, i would try } if (e) } printf("Hi\n"),return; }but this gives syntax error. (at least in the compilers i've tried) }Note that } if (e) } printf("Hi\n"),exit(); }compiles fine. It's just that "return" is treated differently. Return is "treated differently" because it is a statement, not an expression--exit being a function is an expression. (wouldn't it be even more obfuscating and fun is all C statements were also expressions!! [holy shades of BLISS]) I use something like this for that reason: #define GAG(msg,cond) return(printf("...%s\n", msg), cond) if (e) GAG("Why the devil is `e' true?", ERR_ETRUE); John Hascall ISU Comp Center Ames IA