[webkit-dev] Switch statement indentation

Chris Marrin cmarrin at apple.com
Wed Dec 2 16:58:21 PST 2009


On Dec 2, 2009, at 4:47 PM, Alexey Proskuryakov wrote:

>
> On 02.12.2009, at 15:25, Chris Marrin wrote:
>
>> Maybe we could change the style rule in the interest of changing  
>> fewer files (and because I think it generally reads better)?
>
>
> I support changing or dropping this rule. Because of this rule,  
> there is no good way to format cases that need braces, such as:
>
>  switch (i) {
>  case 1: {
>      String a("a");
>      break;
>  }
>  case 2: {
>      String b("b");
>      break;
>  }
>  }
>
> The downside is that some code can get indented too far, which is  
> particularly unfortunate for large switches. But I'm not convinced  
> that having a standard for this improves consistency of the code in  
> any meaningful way (*), perhaps this should be decided on a case by  
> case basis.


The "indented too far" problem can be solved by sticking really big  
switches in their own function. I think this is better style anyway.  
I've always found huge switches in the middle of a long function to be  
very confusing.

-----
~Chris
cmarrin at apple.com






More information about the webkit-dev mailing list