One more point regarding = and == (more flamage)

Blair P. Houghton bhoughto at hopi.intel.com
Wed Mar 27 13:54:46 AEST 1991


In article <925 at isgtec.UUCP> robert at isgtec.UUCP writes:
>In article <355 at smds.UUCP>, rh at smds.UUCP (Richard Harter) writes:
>|> Re:
>|>  a) while (*foo++ = *bar++)
>|>  b) while (*foo ++ == *bar++)
>|>  c) while ((*foo++ = *bar++) != 0)
>|> 
>|> Sundry claims have been made that (c) is "good style" versus (a).  The
>|> original objection was couched in terms of "testing on assignment inside
>|> conditionals is bad form".  IMNSHO most of the arguments and dogmatic
>|> statements are so much rubbish.
>Well the biggest argument has been if you use a) the maintainer can't tell
>if you meant a) or b);  if you use c) the maintainer KNOWS you meant a).
>This isn't rubbish.

I was considering this just this morning, and came to the
conclusion that (1) any maintainer that dumb still has no clue
about b); and, (2) a lot of repetitive stylistics become
mechanized, and it's easy to type that != 0 when you don't
really mean it, at 4:30am, when you're down to chewing the
styrofoam cup from your last cup of coffee...

So in the first case it's only half a fix (properly glued-down
comments are whole and beautiful), and in the second it's
seven extra characters waiting for lint2000(1) to grok their
precisely _intended_ place in the universe.

I have new lollipops screen-printed with calligraphic images
of c) for those humans who are also waiting for such a lint...

				--Blair
				  "Ahh, 4:30am.  It's traditionally
				   when most fortuitous errors occur..."



More information about the Comp.lang.c mailing list