C style peeve and knowing the rules

Barry Margolin barmar at think.com
Tue Mar 27 16:08:03 AEST 1990


In article <689 at sagpd1.UUCP> jharkins at sagpd1.UUCP (Jim Harkins) writes:
>In article <19356 at megaron.cs.arizona.edu> robert at cs.arizona.edu (Robert J. Drabek) writes:
>>I require my students to use the absolute minimum number of parenthesis
>>until they have ALL the rules down pat.
>My God I hope I never ever run into one of your students.  Pray tell, what
>does
>	x = *a->b++ + ++z / 3 << 9^6 + 3 >> 2 ^ 5 <= 98 *~ c % d--;

That expression has problems, but adding parentheses would hardly solve
them.  I don't think I'd understand it unless it were broken up into
multiple assignment statements, with mnemonic variable names for the
temporaries.  Alternatively, comments would be nice, and if they were good
they would serve as well as mnemonic variables and parentheses.

Presumably the author of such a statement originally developed it in a
stepwise fashion, which would be mirrored by the multiple statement
version.  Then he merged them into one statement for performance reasons,
and then removed parens for some perverted reason.  The comments I
mentioned above could just be the original multiple statements!
--
Barry Margolin, Thinking Machines Corp.

barmar at think.com
{uunet,harvard}!think!barmar



More information about the Comp.lang.c mailing list