Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!spool.mu.edu!snorkelwacker.mit.edu!bloom-picayune.mit.edu!news From: scs@adam.mit.edu (Steve Summit) Newsgroups: comp.lang.c Subject: Re: One more point regarding = and == (more flamage) Message-ID: <1991Mar28.073455.27783@athena.mit.edu> Date: 28 Mar 91 07:34:55 GMT Article-I.D.: athena.1991Mar28.073455.27783 References: <13603@helios.TAMU.EDU> <1991Mar22.173037.26641@zoo.toronto.edu> <1991Mar27.184833.7914@sq.sq.com> Sender: news@athena.mit.edu (News system) Reply-To: scs@adam.mit.edu Organization: Thermal Technologies, Cambridge, MA Lines: 36 In article <1991Mar27.184833.7914@sq.sq.com> dak@sq.sq.com (David A Keldsen) writes: >henry@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@adam.mit.edu