Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!husc6!bu-cs!buengc!bph From: bph@buengc.BU.EDU (Blair P. Houghton) Newsgroups: comp.lang.c Subject: Re: comma operator Message-ID: <3612@buengc.BU.EDU> Date: 4 Aug 89 17:34:14 GMT References: <2963@solo6.cs.vu.nl> <2135@zaphod.axion.bt.co.uk> Reply-To: bph@buengc.bu.edu (Blair P. Houghton) Followup-To: comp.lang.c Organization: Boston Univ. Col. of Eng. Lines: 37 In article <2135@zaphod.axion.bt.co.uk> skilbane@zaphod.axion.bt.co.uk writes: >From article <2963@solo6.cs.vu.nl>, by roemer@cs.vu.nl (Roemer Lievaart): >> tada@athena.mit.edu (Michael Zehr) writes: > >Personally, I think it is worse that {;}. If you have something of the form > > x = Expr1 , Expr2; > >then Expr2 will be assigned to x, rather than Expr1. If you rewrite them as No. For precedence, the comma operator is the lowest of the low. Checking the table on p. 18 of Andrew Koenig's _C_Traps_and_Pitfalls_ (I'd have looked in K&RI, but Andy's book was closer). One sees that the bottom three, in decreasing order, are ?: assignments , so in the example above, x would be assigned Expr1, and the statement would "return" the value of Expr2, esentially returning it nowhere, the implications of which are moot, and were discussed here sometime around January. E.g., x = a ? b : c , a ? c : b ; As far as x is concerned, this reads as if ( a != 0 ) x = b; else x = c; --Blair " what ? me : worry ; "