A question of style

Andrew P. Mullhaupt amull at Morgan.COM
Mon Dec 11 11:10:52 AEST 1989


In article <257E97F4.24962 at ateng.com>, chip at ateng.com (Chip Salzenberg) writes:
> The general rule I adhere to most strictly is:  "Repetition is evil."
> For example, "i = i + 1" is inherently harder to read than "i++", since the
> former requires the identification of two variable names (albeit identical
> ones) whereas the latter only contains one name.  The expression
> "c=getchar(), c!=EOF" is harder to read than "(c = getchar()) != EOF" for
> the same reason.

Isn't it possible that in some places repetition can increase
readability? I don't really object to your conclusion here, but
in those cases where avoiding repetition to the utmost requires
sharp use of precendence rules, and only to avoid repetition, I
take issue. I think that operator precedence often breaks up the
ability to read code from one end of the line to the other, especially
when casts are involved, and this takes work to disentangle. I'd
rather break some expressions into more than one part just to keep
the lid on the complexity, even if I need to see the same thing twice
in a row. The elimination of all redundancy, which seems the 
logical extrapolation of your strict adherence to your rule, is
not likely to help me read the code.

Later,
Andrew Mullhaupt



More information about the Comp.lang.c mailing list