Newsgroups: alt.folklore.computers
Date: Mon, 14 Sep 1992 00:48:04 -0400 
From: "Joseph M. Newcomer" <jn11+@andrew.cmu.edu>
Subject: Re: Indentation

Just when you thought it was safe to get back on a.f.c.
    HE'S B-A-A-CK
(at least for a while)

I finally found some time to clean up my act (and my old CMU filespace)
so I can now send and receive messages.  I *still* haven't got my
network node activated as I don't have time to get the damned software
up (I would like to buy a supported uucp-on-DOS package if anyone has
a reccomendation.  I have a machine that can be devoted exclusively to
netmail).

I have an indentation style that is based on some careful studies of
what wastes time when reading programs, and which is based upon some
understanding of human perception mechanisms.

In studying carefully for years what I needed, I came to the conclusion
that the block names of SAIL were the best idea since block structure
was invented.  The compiler checked to make sure that the block name
on the END was the same as the block name of the BEGIN.  So what I did
many years ago was introduce block names into C by programming my editor
(Lugaru's Epsilon) to have the following behavior:

When a '{' is typed at the left margin, auto-indent it and put a comment
following:
        { /* #_*/
the # is a character from the high-order-8-bit space.  The cursor is
left pointing just after the #.

The # has the special property that if you type a character on it or after
it, it disappears and is replaced by the character, but that is a fine point.

When a '}' is typed, I get a flash to the matching '{', the '}' is indented
to be properly placed directly under the '}', and the block comment is
copied down:
     if (condition)
        { /* fix value */
         ...
        } /* fix value */

this means that I never, ever, ever have to say "what open brace does this
close brace match".  It matches the one with the same comment.  Of all
the errors that can be made, and all the arguments for readability, this
is the most effective one.  By putting a meaningful comment in the block,
the readability of the program is vastly improved.  All arguments about
vertical spacing are meaningless compared to the simple ability to instantly
see exactly where the matching blocks are.  I am so crippled without this
that I spent a month fixing up the CMU ATK editor to do block matching
and comment copying.  Of course with it I could get fancy fonts, both on
the screen and on paper, which was even nicer (while the standard font
was a 10-point fixed-pitch font, the block comments were in 8-point
Times Italic, which looked really neat).

This goes along with the view that programs should be written to be 
maintained, not to be compact.

(I once saw a letter in which BASIC was shown to be a far, far better
programming language than FORTRAN or C because you could write a trivial
program in only 19 characters, as opposed to the 45 in C or the 50+ of
FORTRAN.  Obviously smaller is better.  Which makes sense if your entire
programming career consists of writing 3-line throwaway programs).

The automatching goes back to one of my arguments about extensible editors:
there are some people who believe that the purpose of editors is to put
characters in files.  There are others who believe that the purpose of
editors is to help them do their job.  Since no editor can /a priori/
be built that knows what "the job" is, only extensible editors make
sense.  In the WYSIWYG era, this important fact seems to be ignored
in favor of programs that let you enter characters in files.

I am going in again next month for more surgery to correct the damage done
by using an IBM mouse.  I typed for 28 years without a problem.  "Save
me from mouse-based interfaces" is more than a philosophical point with
me.  I am again in constant pain because the first surgery only corrected
the (more serious and more obvious) carpal tunnel problem; a year later
my hand had not recovered.  If anyone knows a serious competitor to a
mouse (not a trackball; something that takes almost zero pressure to
activate) I am in serious need.
                            joe