Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uunet!ateng!chip From: chip@ateng.com (Chip Salzenberg) Newsgroups: comp.lang.c Subject: Re: A question of style Message-ID: <2583D87E.22524@ateng.com> Date: 11 Dec 89 16:40:28 GMT References: <1989Nov23.170838.10376@phri.nyu.edu> <680014@hpmwjaa.HP.COM> <257E97F4.24962@ateng.com> <621@chem.ucsd.EDU> Organization: A T Engineering, Tampa, FL Lines: 38 According to tps@chem.ucsd.edu (Tom Stockfisch): >I think the point here is that style evolves, and wouldn't if people never >strayed from K&R. For instance, what if I justified my use of > > while (*s++ = *t++) > ; > >by quoting K&R (I p. 101, II p. 106)? You're right. Style evolves. However, stylistic evolution based on common errors is different from arbitrary changes based on personal preference. Your example contains an assignment used as a boolean value, which is a questionable practice at best, due to the possibility of "="/"==" error. So the alternative "while ((*s++ = *t++) != 0) {}" is demonstrably better. On the other hand, I'd say that "c=getchar(), c!=EOF" provides little, if any, benefit over "(c = getchar()) != EOF". It has the advantage of fewer parentheses, true, but it has the disadvantage of multiple references to the single variable. In my opinion, it's not a worthwhile tradeoff. >Perhaps it is just because I have never learned lisp, but what *I* find >most difficult to read are multiple sets of parentheses. I hate LISP, aka Lots of Irritating Stupid Parentheses. But we're not talking brain surgery here. My getchar() expression nests only one level deeper than "c=getchar(), c!=EOF". I usually parse it visually this way: if ((c = getchar()) != EOF) ^ open^ ^ ^close two open two close >Am I the only person who is slowed down by lots of parentheses? Idioms are easy to parse once you're used to them. Use tricks, as above. -- You may redistribute this article only to those who may freely do likewise. Chip Salzenberg at A T Engineering; or "The Usenet, in a very real sense, does not exist."