lucy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marvin Humphrey <>
Subject Re: [lucy-dev] C code formatter
Date Sun, 10 Apr 2011 05:39:40 GMT
On Fri, Apr 08, 2011 at 10:38:56PM -0700, Nathan Kurz wrote:
> Demand:
> I'm happy with one line:
>    if (foo) do_it();

Our code base has fair number of lines that look like that, but I've
personally changed over to using brackets most everywhere -- including
single-line conditional statements.

    if (foo) { do_this(); }
    else     { do_that(); }

> And happy with brackets:
>   if (foo) {
>       do_it();
>   }
> But I believe fairly strongly that one should avoid:
>   if (foo)
>      do_it();
> I think it leads to enough subtle errors that one just shouldn't
> do_it(), especially with a code formatter that means that one might
> not notice the "corrected" indentation.

Good point.  I agree that auto-formatting increases the danger.  

Since this is a popular critique out in the world and we seem to have reached
consensus in here, I've gone and swept through the code base adding brackets
to all existing instances of that idiom with r1090538.

> If "--add-brackets" is compatible with "--keep-one-line-statements",
> I'd love if it could be added as well.

I think --keep-one-line-statements is important.  I'm open to the idea of
enforcing brackets.

> Discussion:
> I appreciate the compactness of the "--brackets=attach" style, which
> avoids the mostly blank line below each function definition and puts
> the opening bracket on the same line.  Is "--brackets=linux" something
> you feel strongly about?  I'm not against it if you think it helps
> with reading or text processing, but it seemed worth discussing.

I'm OK with with "--brackets=attach".
Marvin Humphrey

View raw message