On Tue, Dec 25, 2012 at 2:31 AM, Sean Silva <[email protected]> wrote:

> On Tue, Dec 25, 2012 at 3:10 AM, Daniel Jasper <[email protected]> wrote:
> > } else if (aaaaaaaa ==
> >            bbbbbbbb) ...
>
> My gut feeling is that most people would prefer this one.
>

Given this example, I agree. I think it gets more complicated though:

} else if (aaaaaaaa ==
           bbbbbbbb &&
           cccccccc ==
           dddddddd) {

So, here we have a bit of a conundrum. In an ideal world, what I would
really like is to see an indentation strategy which indicates operator
precedence easily to the reader. Now, I've never imagined actually doing
this because I'd just get it wrong and never update it. But with
clang-format, I think the more complex formatting might be something worth
considering.... But I've not yet come up with a good set of rules that
would format consistently and well while indicating precedence whenever
possible. Maybe Daniel has some strategies in mind? I've not thought much
about it. In this limited case, I would personally find the following ever
so slightly easier to read:

} else if (aaaaaaaa ==
               bbbbbbbb &&
           cccccccc ==
               dddddddd) {

Mostly this is because I subscribe to the 'black indent of 2 spaces, line
continuation of 4 spaces' school of formatting, and I'm just using
indentation is a blunt instrument to indicate grouping. If extra
parentheses weren't used to silence valuable warnings, my preference would
be:

} else if ((aaaaaaaa ==
            bbbbbbbb) &&
           (cccccccc ==
            dddddddd)) {
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to