Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!bloom-beacon!bu-cs!buengc!bph From: bph@buengc.BU.EDU (Blair P. Houghton) Newsgroups: comp.lang.c Subject: Re: comma operator Message-ID: <3620@buengc.BU.EDU> Date: 5 Aug 89 17:12:57 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: bph@buengc.bu.edu (Blair P. Houghton) Followup-To: comp.lang.c Organization: Boston Univ. Col. of Eng. Lines: 37 In article <9736@alice.UUCP> debra@alice.UUCP () writes: > > if (e) > printf("Hi\n"),return; > >gives syntax error. (at least in the compilers i've tried) > > if (e) > printf("Hi\n"),exit(); > >compiles fine. It's just that "return" is treated differently. BECAUSE IT'S A STATEMENT!! Pardon the tone, but this is actually a joke I'm telling, here... Several of you will get it. Go to the next article while I explain... The original examples in this subject thread used fprintf(...) , exit(0) ; and I made the mistake of thinking these were statements and I flamed on that point and I was soundly thrashed for my misstatements. The return statement, however, is just that, a statement. The things on either side of a comma opertor must be expressions. The element formed by expressions and comma operators is itself an expression. You can't stick for-loops in a comma-expression, for example. The syntax summary at the back of K&R is probably the best place to find a concise definition of the distinction between expressions and statements --Blair "Vindication is satisfying, which is also an expression."