Indent! Indent! (was Re: Proposal for a scientific look at C style choices)

T. William Wells bill at twwells.uucp
Fri Jan 6 03:46:38 AEST 1989


In article <9279 at ihlpb.ATT.COM> nevin1 at ihlpb.UUCP (55528-Liber,N.J.) writes:
: In article <272 at twwells.uucp> bill at twwells.UUCP (T. William Wells) writes:
: >I consider the braces as a separate element: sometimes necessary for
: >the compiler (but I always use the braces), but contributing little or
: >nothing to the understandability of the program.
:
: If the braces are necessary for the compiler (which they sometimes
: are), then they do contribute to the understandability of the program.
: Otherwise they wouldn't be necessary!

Hardly. You are confusing the compiler with yourself: the braces may
be necessary for the compiler, but you, hopefully, are smarter, and
can figure out what is going on from the indentation.  Hell, that
isn't even your conscious mind doing the job, just your subconscious.

: >The indentation of
: >the program is what tells you the control relationships; the braces
: >are redundant information, at best they can augment what the
: >indentation is alreaddy telling you.
:
: I feel the opposite is true (indentation provides the redundant
: information, not the braces).  If the braces are wrong, my program
: probably won't do what I intended it to do.

Again you confuse the issue. The question is not whether one should
place the braces in the code in order to make it correct.  (One
should *always* use the braces, for reasons I've stated elsewhere.)
The question is which contributes best to understandability.  And
indentation is unquestionably the better for this purpose.  (See my
previous posting on this topic for why.)

:                                              If the indentation is
: wrong, my program can still compile and run correctly.  Indentation are
: like comments in that there is nothing to enforce them being correct.

I suppose you believe that you are a low grade moron, incapable of
doing indentation correctly? I suppose you think other programmers are
the same?

Horseshit.

It is so easy to get indentation right that I *never* make mistakes
with it and I don't mean almost never. And y'all know how unlikely it
is for a programmer to get it right the first time, right? :-) Never
mind *every* time.

In other words, your belief that people might get them wrong is
insufficient justification: people might occasionally get them wrong,
but the odds are very much against it.

: For maintaining other people's code, I can only rely on the same things
: that the compiler relies on (in this case, the braces instead of the
: indentation).

For maintaining other people's code, if the indentation and comments
aren't right, I fix them. And indentation is *so* easy to fix, there
is just no excuse for letting bad indentation continue to exist.

Any other approach to dealing with bad code just makes the bad code
worse.

Any rationalization for not fixing bad code is just a disguise for
laziness or slovenliness.

---
Bill
{ uunet!proxftl | novavax } !twwells!bill



More information about the Comp.lang.c mailing list