[webkit-dev] Resolution on switch statement indentation

Maciej Stachowiak mjs at apple.com
Wed Dec 9 09:41:52 PST 2009


On Dec 9, 2009, at 7:26 AM, Chris Marrin wrote:

>
> I saw another patch get rejected today because of switch statement  
> indentation. We discussed this last week, and I saw a lot of support  
> for my proposal of indenting case labels from their switch. But the  
> discussion did not end in resolution. To summarize, here are the  
> options mentioned:
>
> 1) Case labels always have the same indentation as their switch  
> (today's rule)
>
> 2) Case labels always indent 4 spaces in from their switch (my  
> preference)
>
> 3) Case labels indent 2 spaces in from their switch. (Maciej's rule)
>
> I was a little unclear on Maciej's rule. The last part of his rule  
> is "In the case where a case label is followed by a block, include  
> the open brace on the same line as the case label and indent the  
> matching close brace only two spaces (but still 4 spaces for the  
> contained statements)". Did he mean that the contained statements  
> would be indented 4 spaces from the case label, meaning they would  
> be indented 6 spaces from the switch?

I meant 4 spaces from the switch (i.e. 2 additional spaces from the  
case label).

switch (x) {
   case foo: {
     fooFunc();
   }
   case bar:
     barFunc();
}

  - Maciej



More information about the webkit-dev mailing list