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

JINMEI Tatuya / 神明達哉 jinmei at isc.org
Tue Feb 15 08:21:38 UTC 2011


At Thu, 03 Feb 2011 21:35:41 +0100,
Jelte Jansen <jelte at isc.org> 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).

> 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).

Do you mean something like this?

    if (JS_DefineProperty(cx, o, "data", STRING_TO_JSVAL(
                              JS_NewStringCopyN(cx, data, res)),
                          NULL, NULL, JSPROP_ENUMERATE) != 0) {
    }

If so, I also use it when the expression would be too long if
represented in a single line.  I admit this is less readable.

> 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 :)

I prefer using a single style (one style or another) because currently
different people having different preferences edit the same file,
yielding a mixture of styles in the same file and sometimes
unnecessary changes as a side effect of a non style change (which
increases the load of code review).

---
JINMEI, Tatuya



More information about the bind10-dev mailing list