[webkit-dev] Proposing style guide change regarding braces on conditional arms

Dirk Pranke dpranke at chromium.org
Thu Dec 3 18:39:58 PST 2009


+1. Peter's is better than Maciej's is better than status quo.

-- Dirk

On Thu, Dec 3, 2009 at 6:24 PM, Jeremy Orlow <jorlow at chromium.org> wrote:
> On Thu, Dec 3, 2009 at 6:15 PM, Maciej Stachowiak <mjs at apple.com> wrote:
>>
>> On Dec 3, 2009, at 5:48 PM, Michael Nordman wrote:
>>
>> what peter pitched and what mjs pitched are one and the same i think
>>
>> * When all arms of a conditional or loop are one physical line, do not use
>> braces.  If any arms are more than one physical line (even if they are one
>> logical line), use braces on all arms.
>>>>>
>>>>> One possible conservative modification to the rule is that if you have
>>>>> a multi-block if ... else if ... else chain, then if even one body has
>>>>> braces, all should. I think that would tend to reduce rather than increase
>>>>> visual noise, as all the "else" keywords would line up where right now they
>>>>> look ragged.
>>
>> To be clear: my intent was to propose something different than Peter's
>> suggestion. Specifically, I suggest we do *not* change the rule for a simple
>> if/else statement with only two clauses. Those would still be able to have
>> braces on only one of the two clauses. But if/else chains of more than two
>> clauses would have to be consistent.
>> For anyone who agreed with my suggestion, you may want to consider whether
>> you still agree in light of this clarification.
>
> Is this formally up for a vote then?
> For what it's worth, I think Peters is the most readable, but Maciej's is
> better than what it is now.  I find stuff like
> if (blah)
>   blah
> else {
>   blah
> }
> very distracting.  But stuff like
> if (blah)
>   blah
> else if (blah)
>   blah
> else if (blah) {
>   blah
> } else
>   blah
> is definitely even worse.
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
>
>


More information about the webkit-dev mailing list