Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 May 1996 13:44:21 +0200 (MET DST)
From:      grog@lemis.de (Greg Lehey)
To:        bde@zeta.org.au (Bruce Evans)
Cc:        hackers@freebsd.org (FreeBSD Hackers)
Subject:   Re: Indentation styles
Message-ID:  <199605281144.NAA23631@allegro.lemis.de>
In-Reply-To: <199605281035.UAA13366@godzilla.zeta.org.au> from "Bruce Evans" at May 28, 96 08:35:53 pm

next in thread | previous in thread | raw e-mail | index | archive | help
Bruce Evans writes:
>
>> First, a question: is there a recommended FreeBSD indentation style?
>
> Yes.  See style.9 in -current or /usr/src/admin/style/style in 4.4BSD.

Thanks.

>> Now, my problem: I frequently modify other people's code, which
>> sometimes causes me problems in reading, simply because the
>> indentation varies so much from the indentation that my tools and I
>> use.  Frequently, I just give up and run the whole source through
>> indent(1).  The resulting modifications work (usually), but it's
>> difficult to pass them back to the original author as diffs.
>
> Don't use indent on other peoples code.

What's the alternative?  My tools don't understand a lot of the code
out there, and I have difficulty.

>> Therefore, my suggestion: if FreeBSD doesn't have a canonical
>> indentation style, it should get one.  The style should be
>> reproducible with indent(1). (For those of you who don't know,
>
> BSD indent is too broken to produce BSD style :-(.  It can only
> produce an approximation that looks OK but has too many differences
> for automatic use.

What about GNU indent?  Or is that NIH? 

>> If there is already a recommended FreeBSD indentation style, can it be
>> reliably produced with indent(1)?  If not, what do people think about
>> modifying it to a (closely similar) form which can be created with
>> indent(1)?
>
> indent(1) should be changed, not the style.  Otherwise 200MB of current
> sources that sort of have the correct style would have the wrong style.

Obviously it would only be possible to accept changes if they were
small.  I've done some tests with a couple of kernel modules, and
though they didn't end up looking exactly the same, there was no
reason to assume that the new version was any less in accordance with
the style guidelines than the old version.  There are probably a few
flags to tweak, but there's little point unless people can agree on
this kind of procedure.

>> Finally, a restriction.  Indent style can, in some cases, influence
>> coding style: for example, if you choose an indent of 8 and indent
>> braces 8 characters and the contents of a block another 8 spaces,
>> you'll soon run out of margins.  Even if you only indent a single 8
>> characters, you'll end up writing different code from people running
>> smaller indents.  Does this matter?
>
> 8 is too much but we're stuck with it.  There is something to be said
> for the discipline required to minimise nesting.  Don't right code like
> this:
>
> {
> 	{
> 		{
> 			{
> 				{
> 					{
> 						{
> 							{
> 								{
> 									/*
> 									 * Com-
> 									 * men-
> 									 * ts
> 									 * are
> 									 * hard
> 									 * to
> 									 * fit
> 									 * bet-
> 									 * wee-
> 									 * n
> 									 * col-
> 									 * umns
> 									 * 72
> 									 * and
> 									 * 80.
> 									 */
> 									 {
> 									/*->*/	{
> 									/*->*/	    /* Some people's xterms are too wide. */

Precisely :-)  But why are we stuck with 8 characters?  I can't find
anything about it in style(9).  It says "Second level indents are four
spaces." and then proceeds to show examples with 8 character indents.

Greg



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199605281144.NAA23631>