comma operator: keep away?

Doug Gwyn gwyn at smoke.BRL.MIL
Thu Apr 27 14:14:52 AEST 1989


In article <1989Apr26.214622.10697 at utzoo.uucp> henry at utzoo.uucp (Henry Spencer) writes:
>As my original posting said, it is a well-established fact, backed by
>various experiments on things like reading rates, that familiar styles
>are easier to read.  This particular comma construct is uncommon and
>hence likely to be unfamiliar.  QED.

Oh, come on, Henry, what is "common" or "familiar" depends very much
on one's experience.  There are many common cases of truly horrible
coding style, and most of us are familiar with examples of it.  That
in itself does not make it easier to read, desirable, or anything
else along those lines.  The best one can say is that familiarity is
one positive factor in code readability, but there are many others too.
Clear logical structure is probably more important.

While I don't recommend unbridled use of comma operators in place of
semicolons, neither would I call usage such as
	while ( norm( x, y, z ) < distance )
		++x, ++y, ++z;
"unreadable".  It seems to me that it would be perfectly readable
to anyone who should be attempting to deal with C code at all.  It may
even be preferable to adding the extra punctuation that you recommend.



More information about the Comp.unix.questions mailing list