more about programming style

alex at ucla-cs.UUCP alex at ucla-cs.UUCP
Mon Aug 5 12:59:47 AEST 1985


In article <4067 at alice.UUCP> ark at alice.UUCP (Andrew Koenig) writes:
>>I would appreciate comments, suggestions, etc. on additional ways to
>>make type declarations more readable.
>
>The easiest way to make them more readable is to learn how to read them.

WRONG!  The easiest way to make programs more readable is to keep
readability in mind when you write them.  It has nothing to do with
learning how to read very obscure type declarations or having memorized
the C operator precedence table.  So you can understand:

    int (*foo[10])();

That doesn't help someone who is reading your program who doesn't.
But writing the declaration as done below does.

    typedef int (*PFI)();          /* pointer to function returning int */
    PFI foo[10];

While knowing how to read complicated declarations may help you meet
girls at cocktail parties, it doesn't help your program's reader!

Alex



More information about the Comp.lang.c mailing list