Bit Switching - How? (really co

joe at gistdev.UUCP joe at gistdev.UUCP
Wed Apr 19 23:15:00 AEST 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.



More information about the Comp.lang.c mailing list