C format
utzoo!decvax!duke!harpo!npoiv!npois!!mark
utzoo!decvax!duke!harpo!npoiv!npois!!mark
Fri Oct 22 21:00:36 AEST 1982
Popular programming languages of late (Algol 68, Ada, FORTRAN 77) that
solved dangling else with a "fi" type terminator all seem to recommend
indenting along the lines of
if test then
do something
else
don't do something
endif
Notice that the "if" itself (and its associated syntax) is at one level
of indenting, and the nested statements are at the next level. If you
extrapolate this indenting style to C, you get
if (test) {
do something
} else {
don't do something
}
(You could even carry it to the Bourne extreme visible in sh and adb.)
The alternative to the above would read like
if (test)
{
do something
}
else
{
don't do something
}
which you'll notice takes an extra 3 lines. Given the current situation that
we mostly have screens with only 24 lines, any indenting practice that makes
a big cut in how much code fits on your screen at once is probably not all
that wonderful an idea.
No, I don't advocate putting 5.5 statements per line to make an entire C
source file fit on one screen. What I advocate is bigger screens. But
I do prefer the more compact style.
More information about the Comp.lang.c
mailing list