[net.lang.c] *less* about style and more about correctness

garys@bunker.UUCP (Gary M. Samuelson) (07/15/85)

Never mind which idiom produces more efficient object
code; you better figure out it's supposed to do first.

If you write:

> 	while (p->duck)
> 		p++;

instead of

> 	while (p++->duck)
> 		;

you will get different results. in the first case, 'p' will
point to the structure/union where 'duck' was first found to
be null; in the second case, 'p' will point to the structure/union
*following* the one where 'duck' was found to be null.

Both of the above fragments are obscure.  The fix is, as someone
else suggested, to write a comment to indicate what is supposed
to happen.  E.g.:

	/* Find a null 'duck' */
	while (p->duck)
		p++;

or

	/* Skip the next null 'duck' */
	while (p++ -> duck)
		;

*Now* we might discuss stylistic questions, like what kind and
how much white space should be used to improve readability  (I
already added some in the second case to separate the operators),
or where the comment should be.

Gary Samuelson