<br><br>On Wednesday, August 12, 2015, Junxiao Shi <<a href="mailto:shijunxiao@email.arizona.edu">shijunxiao@email.arizona.edu</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US"><div><p class="MsoNormal">Dear folks</p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Incorporating suggestions from Eric and Wentao:</p><p class="MsoNormal"><u></u> <u></u></p><p style="margin-left:.5in"><span style="font-family:Consolas">// option E<u></u><u></u></span></p><p style="margin-left:.5in"><span style="font-family:Consolas">switch (cond) {<u></u><u></u></span></p><p style="margin-left:.5in"><span style="font-family:Consolas">  case 1:<u></u><u></u></span></p><p style="margin-left:.5in"><span style="font-family:Consolas">  {<u></u><u></u></span></p><p style="margin-left:.5in"><span style="font-family:Consolas">    int i = 1;<u></u><u></u></span></p><p style="margin-left:.5in"><span style="font-family:Consolas">    doSomething(i);<u></u><u></u></span></p><p style="margin-left:.5in"><span style="font-family:Consolas">    // Fallthrough<u></u><u></u></span></p><p style="margin-left:.5in"><span style="font-family:Consolas">  }<u></u><u></u></span></p><p style="margin-left:.5in"><span style="font-family:Consolas"><u></u> <u></u></span></p><p style="margin-left:.5in"><span style="font-family:Consolas">  case 2:<u></u><u></u></span></p><p style="margin-left:.5in"><span style="font-family:Consolas">  {<u></u><u></u></span></p><p style="margin-left:.5in"><span style="font-family:Consolas">    doSomething(2);<u></u><u></u></span></p><p style="margin-left:.5in"><span style="font-family:Consolas">    break;<u></u><u></u></span></p><p style="margin-left:.5in"><span style="font-family:Consolas">  }<u></u><u></u></span></p><p style="margin-left:.5in"><span style="font-family:Consolas"><u></u> <u></u></span></p><p style="margin-left:.5in"><span style="font-family:Consolas">  case 3:<u></u><u></u></span></p><p style="margin-left:.5in"><span style="font-family:Consolas">  {<u></u><u></u></span></p><p style="margin-left:.5in"><span style="font-family:Consolas">    int j = 3;<u></u><u></u></span></p><p style="margin-left:.5in"><span style="font-family:Consolas">    doSomething(j);<u></u><u></u></span></p><p style="margin-left:.5in"><span style="font-family:Consolas">    break;<u></u><u></u></span></p><p style="margin-left:.5in"><span style="font-family:Consolas">  }<u></u><u></u></span></p><p style="margin-left:.5in"><span style="font-family:Consolas"><u></u> <u></u></span></p><p style="margin-left:.5in"><span style="font-family:Consolas">  default:<u></u><u></u></span></p><p style="margin-left:.5in"><span style="font-family:Consolas">  {<u></u><u></u></span></p><p style="margin-left:.5in"><span style="font-family:Consolas">    doSomething(0);<u></u><u></u></span></p><p style="margin-left:.5in"><span style="font-family:Consolas">    break;<u></u><u></u></span></p><p style="margin-left:.5in"><span style="font-family:Consolas">  }<u></u><u></u></span></p><p style="margin-left:.5in"><span style="font-family:Consolas">}<u></u><u></u></span></p><p class="MsoNormal"><u></u> <u></u></p><p><u></u><span style="font-family:Symbol"><span>·<span style="font:7.0pt "Times New Roman"">         </span></span></span><u></u>When any ‘case’ or ‘default’ contains a declaration and therefore needs a compound statement, all ‘case’s and ‘default’ must use compound statements.</p></div></div></blockquote><div>I wouldn't go that far as to require all cases to have the same format. I think it's ok to mix blocked case and non-blocked case, as long as the block covers the entire single case branch. But the current specification (option E by Junxiao) also looks fine to me.<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US"><div><p><u></u><span style="font-family:Symbol"><span>·<span style="font:7.0pt "Times New Roman"">         </span></span></span><u></u>When using compound statements, ‘case’ and ‘default’ should be indented two spaces after ‘switch’, ‘{‘ and ‘}’ of the compound statements are indented at the same level as ‘case’ and ‘default’, and statements within the compound statements are indented two spaces after ‘case’ and ‘default’.</p><p><u></u><span style="font-family:Symbol"><span>·<span style="font:7.0pt "Times New Roman"">         </span></span></span><u></u>‘break’ and ‘// Fallthrough’ should be placed inside compound statements.</p></div></div></blockquote><div>I would suggest one more readability requirement: any intentional fall-through MUST be explicitly annotated in the code. (Do we have this rule already? I can't remember.)</div><div><br></div><div>Wentao <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US"><div><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">A ‘switch’ statement without compound statements should still be formatted in the current way, i.e. no extra indentation for ‘case’ and ‘default’.</p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Any more comments?</p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Yours, Junxiao</p></div></div></blockquote><br><br>-- <br><div dir="ltr">PhD @ IRL, CSD, UCLA</div><br>