Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!uxc!uxc.cso.uiuc.edu!gistdev!joe From: joe@gistdev.UUCP Newsgroups: comp.lang.c Subject: Re: Bit Switching - How? (really co Message-ID: <7800006@gistdev> Date: 19 Apr 89 13:15:00 GMT References: <628@gonzo.UUCP> Lines: 42 Nf-ID: #R:gonzo.UUCP:628:gistdev:7800006:000:1206 Nf-From: gistdev.UUCP!joe Apr 19 08:15:00 1989 % Written 2:15 am Apr 18, 1989 by gonzo.UUCP!daveb in comp.lang.c > I posted a provocative note, the gist of which was that > > if( cond ) > e1, e2; > > was rotten C programming practice for multiple person projects. ...... > > if( cond ) { /* brace placement left as religious discussion */ > e1; > e2; > } > So, I claim 99 out of 100 competent C programmers reading this code > years from now are going to suffer cognitive dissonance on a "comma-ed" > construct when they come upon it. Gee, I must be the other guy, because that type of code can actually be more readable in certain cases. > What does the author get from using a comma? Glad you asked. :-) How about in a situation dealing with coordinates? I think that: if ( cond ) x = xvalue, y = yvalue; is far preferable to: if ( cond ) { x = xvalue; y = yvalue; } If the two operations being performed are logically related, I like seeing them on one line. I really can't see that it makes the code unreadable to do so. I guess if you want to complain about C programming practices, there are many that are far worse than placing two statements on a line with a comma between that obscure maintainability.