[bind10-dev] [bikeshed] C++ indentation style

Jelte Jansen jelte at isc.org
Thu Feb 3 20:35:41 UTC 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 02/03/2011 08:47 PM, JINMEI Tatuya / 神明達哉 wrote:
> I've noticed that recent BIND 10 C++ code has a mixture of two
> different indentation styles for multi-line expressions:
> (traditional?) BSD style and BSD KNF style and  (see
> http://en.wikipedia.org/wiki/Indent_style).
> 
> 1. In the (traditional?) BSD style, continuing lines are aligned with
>    the corresponding opening parenthesis:
> 
> 2. In the KNF style, continuing lines always start at the same column,
>    indented by the size of "soft tab":
> 
> I'd like to keep the style consistent (I have my own preference, which
> is style #1, but I don't mind using a non preferred style if that's
> the group consensus).
> 
> Both styles have pros and cons:
>  - style #1 is (at least seemingly) consistent with other ISC code
>    including BIND 9 and DHCP.
>  - style #1 better clarifies the relationship between a function and
>    its parameters (it's clearer in style #1 that NULLs are parameters
>    of JS_DefineProperty(), not STRING_TO_JSVAL()).
>  - style #2 uses the space more efficiently (style #1 tends to require
>    large redundant spaces in the left side, which can lead to
>    unnecessarily longer lines)
> 
> Does this proposal make sense?  If so, which style do main developers
> prefer?
> 

I must confess I use both; I tend to prefer the first, if space allows, but
sometimes that leads to still going beyond any reasonable line-boundary, in
which case I tend to 'fall back' to the second (rather than putting in
linebreaks at, shall we say, more contrived places). I think I also saw a third,
btw (or maybe I did it), which is a variant on the both, it uses a varying
number of spaces depending on what's on the line above and 'looks good' (so
either aligned with the parenthesis or at some obvious 'marker', if you catch my
drift).

I know this is inconsistent and if people prefer we use a single style I am
happy to follow. Just telling the reasons why I do it like this :)

Jelte
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk1LEZ0ACgkQ4nZCKsdOncWhqACfcQSvpMIWpDY6P0CsBSMjpwhE
++MAnjOVuuLIKRyA5ZQ/DFXes5AlANZI
=B6qX
-----END PGP SIGNATURE-----



More information about the bind10-dev mailing list