A question of style

Tom Stockfisch tps at chem.ucsd.edu
Sun Dec 10 16:52:48 AEST 1989


In article <257E97F4.24962 at ateng.com> chip at ateng.com (Chip Salzenberg) writes:
>According to jeffa at hpmwtd.HP.COM (Jeff Aguilera):
>>I understand (and accept) that most programmers are compelled to use the K&R
>>form, following their masters' dogma blindly, criticizing all others.

>A construct's being quickly identifiable by most C programmers makes that
>thing immediately preferable to an equivalent but less common construct.
>And if there's one book a C programmer has almost certainly read, it's K&R.

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)?

>The general rule I adhere to most strictly is:  "Repetition is evil."
>...  The expression
>"c=getchar(), c!=EOF" is harder to read than "(c = getchar()) != EOF" for
>the same reason.

Perhaps it is just because I have never learned lisp, but what *I* find
most difficult to read are multiple sets of parentheses.  Even though
I have never used Jeff's form before in a "while" construct, I still found
it easier to read than the "standard" notation.  The repetition is
just one character here ("c"), and very close by.  Am I the only person
who is slowed down by lots of parentheses?

Just in case what I have said so far doesn't generate any flames, I'll
offer what I would write for this case:

	for ( c = getchar(); c != EOF; c = getchar() )
-- 

|| Tom Stockfisch, UCSD Chemistry	tps at chem.ucsd.edu



More information about the Comp.lang.c mailing list