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

Steve Summit scs at adam.mit.edu
Thu Mar 28 17:34:55 AEST 1991


In article <1991Mar27.184833.7914 at sq.sq.com> dak at sq.sq.com (David A Keldsen) writes:
>henry at zoo.toronto.edu (Henry Spencer) writes:
>>Deliberately using a construct that looks like a well-known and subtle
>>programming error is a mistake.  Your successor, reading your code, should
>>*never* have to ask himself "is this really right?"
>
>I agree with the principle, but I disagree that it applies here.  The 
>programmer must balance clarity-by-standard-idiom and clarity-by-explicitness.
>
>From K&R1 (p. 101):
>        ...
>        while (*s++ = *t++)
>        ...
>
>"Although this may seem cryptic at first sight, the notational convenience
>is considerable, and the idiom should be mastered, if for no other reason
>than that you will see it frequently in C programs."
>
>I find the idiomatic usage to be clearer, because it is easier to recognize.

I'm sure that many of us who recommend explicit tests are aware
of the cited example in K&R.  Note that _use_ of the idiom is not
condoned, other than obliquely through the undefined concept
"notational convenience."

K&R1 is one of the best programming texts it has ever been my
pleasure to learn from, but it is not perfect.  I have precisely
one real complaint with it, namely the above-quoted example.
Mere mention in K&R does not automatically render a concept
inviolate; we're all allowed to think about these things for
ourselves.

Clearly, though, this is a religious argument.

                                            Steve Summit
                                            scs at adam.mit.edu



More information about the Comp.lang.c mailing list