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

Jeremy Orlow jorlow at chromium.org
Thu Dec 3 18:24:47 PST 2009


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20091203/56fdee73/attachment.html>


More information about the webkit-dev mailing list