Standard Indentation etc.

Mark A Terribile mat at mole-end.UUCP
Fri Dec 16 17:38:04 AEST 1988


> Except the placing of the {} and the if-else I agree with this. The else
> is *absolutely* not equally important as the if; it is only one of the
> two alternatives (see my example with the switch-statement). Placing the
> {} my way uses the same amount of vertical space and is more correct:
> 
>   while (1)         while (1){
>     { first;                first;
>       second();             second();
>       etc;                  etc;
>     }               }
> 
> How do you like this alternative, Gerald Hawkins ?

It's a disaster.  You can't do line manipulation, (either with a line editor
(horrors) or editing by moving lines) without having to worry about your
braces.

My own preference is the ``brace-over-brace'' convention, but the most
important thing in my mind is the consistent and *simple* arrangement of
indentation.  I see only two justifications for fractional-tab indents:

	In the switch(), it seems to help to put two spaces before each
	case.

	In a few large functions that are deeply nested, putting the last
	four or five indents at 4 spaces instead of a natural tab can help.

The second case should be a fourth resort.  The first resort is to get a
clearer picture of the problem so that you can code it with fewer indents;
the second is to arrange your solution in the most linear way possible
(a vine rather than a bushy tree--see Kernighan & Plauger for details) using
early exits where appropriate, and the third is to find a simple way to break
the routine up.  When those fail, go *consistently* to fractional indents for
the *last few* levels ONLY.
-- 

(This man's opinions are his own.)
>From mole-end				Mark Terribile



More information about the Comp.lang.c mailing list