C style peeve and knowing the rules

Art Boyne boyne at hplvli.HP.COM
Wed Mar 28 02:03:09 AEST 1990


hascall at cs.iastate.edu (John Hascall) writes:
>    Operator precedence and associativity in C is quite complicated
>    and somewhat non-intuitive.

An understatement.

ggg at sunquest.UUCP (Guy Greenwald) writes:
>For once, I agree with Robert J. Drabek. If you read his article carefully,
>you'll see he's making a pedagogic point. A student who is required to use
>the minimum number of parentheses will have to understand C's precedence
>rules.

Phooey - certain of the precedence are so counter-intuitive that after
6-1/2 years of programming in C, I still have a copy of K&R1's precedence
chart taped to my wall.  Trying to make a student learn it, and be able
to reproduce it for a test, is ridiculous.  As an employer, I am far more
concerned about whether the student understands what a>b ? x : y does than
whether he writes it as (a>b) ? (x) : (y).

In industry, it costs a *lot* more to find a bug created by omitting a
needed pair of parenthesis than it ever will to pay for the keystrokes
to put in a pair in a doubtful situation.

Art Boyne, boyne at hplvla.hp.com



More information about the Comp.lang.c mailing list