[comp.lang.c] Indent! Indent!

bill@twwells.uucp (T. William Wells) (01/06/89)

In article <9279@ihlpb.ATT.COM> nevin1@ihlpb.UUCP (55528-Liber,N.J.) writes:
: In article <272@twwells.uucp> bill@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

chris@mimsy.UUCP (Chris Torek) (01/06/89)

In article <293@twwells.uucp> bill@twwells.uucp (T. William Wells) writes:
>... 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.

Actually, it is a collection of dedicated-purpose cells in the visual
cortex, whose job is to find vertical lines in the visual field.

The amount of hardwired visual information processing in the brain is
rather astounding.  Since those cells *are* permanently dedicated to
their tasks, indentation recognition is virtually free---which is why
you should use some consistent form of indentation.  (`Virtually'
because you must use softwired cells to translate `line' to `statement
group'.)
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris