A question of style

Jeff Aguilera jeffa at hpmwtd.HP.COM
Sat Dec 2 09:52:53 AEST 1989


>>while (c = getchar(), c != EOF)

Too much annoying white space, conveying no information or structure.  Try

    while (c=getchar(), c!=EOF)

instead.  Pull atomic concepts and actions together.

>The standard C idiom for this is
>    while ( (c = getchar()) != EOF )

Gee.  I prefer the first construct.  Indeed, it is the only one I dare use, 
because it is so much clearer.  But I understand (and accept) that most 
programmers are compelled to use the K&R form, following their masters' dogma
blindly, criticizing all others.

>and experienced C programmers are likely to read the standard idiom
>with greater facility than your proposed use of a comma operator for this.

I hope an experienced programmer is capable of understanding both expressions.
His mental algorithmic model should be independent of the implementation and
its expression.  
-----
jeffa

    Mathematicians are like Frenchmen: whatever you say to them they
    translate into their own language, and forthwith it is something
    entirely different.
            -- Johann Wolfgang von Goethe



More information about the Comp.lang.c mailing list