<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
@font-face
        {font-family:"\@SimSun";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0in;
        margin-right:0in;
        margin-bottom:0in;
        margin-left:.5in;
        margin-bottom:.0001pt;
        mso-add-space:auto;
        line-height:105%;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
p.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, div.MsoListParagraphCxSpFirst
        {mso-style-priority:34;
        mso-style-type:export-only;
        margin-top:0in;
        margin-right:0in;
        margin-bottom:0in;
        margin-left:.5in;
        margin-bottom:.0001pt;
        mso-add-space:auto;
        line-height:105%;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
p.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, div.MsoListParagraphCxSpMiddle
        {mso-style-priority:34;
        mso-style-type:export-only;
        margin-top:0in;
        margin-right:0in;
        margin-bottom:0in;
        margin-left:.5in;
        margin-bottom:.0001pt;
        mso-add-space:auto;
        line-height:105%;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
p.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxSpLast
        {mso-style-priority:34;
        mso-style-type:export-only;
        margin-top:0in;
        margin-right:0in;
        margin-bottom:0in;
        margin-left:.5in;
        margin-bottom:.0001pt;
        mso-add-space:auto;
        line-height:105%;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:449511898;
        mso-list-type:hybrid;
        mso-list-template-ids:-1861814862 67698689 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;}
@list l0:level1
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Symbol;}
@list l0:level2
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l0:level3
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
@list l0:level4
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Symbol;}
@list l0:level5
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l0:level6
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
@list l0:level7
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Symbol;}
@list l0:level8
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l0:level9
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
--></style></head><body lang=EN-US link=blue vlink="#954F72"><div class=WordSection1><p>Dear folks</p><p><o:p> </o:p></p><p>It seems that I misunderstood Wentao’s opinion about not to mix compound and non-compound ‘case’ labels.</p><p>It indeed meant that when a compound statement is used, the ‘break’ or ‘// Fallthrough’ should be inside the compound.</p><p>So:</p><p><o:p> </o:p></p><p style='margin-left:.5in'><span style='font-family:Consolas'>// option F<o:p></o:p></span></p><p style='margin-left:.5in'><span style='font-family:Consolas'>switch (cond) {<o:p></o:p></span></p><p style='margin-left:.5in'><span style='font-family:Consolas'>  case 1:<o:p></o:p></span></p><p style='margin-left:.5in'><span style='font-family:Consolas'>  {<o:p></o:p></span></p><p style='margin-left:.5in'><span style='font-family:Consolas'>    int i = 1;<o:p></o:p></span></p><p style='margin-left:.5in'><span style='font-family:Consolas'>    doSomething(i);<o:p></o:p></span></p><p style='margin-left:.5in'><span style='font-family:Consolas'>    // Fallthrough<o:p></o:p></span></p><p style='margin-left:.5in'><span style='font-family:Consolas'>  }<o:p></o:p></span></p><p style='margin-left:.5in'><span style='font-family:Consolas'><o:p> </o:p></span></p><p style='margin-left:.5in'><span style='font-family:Consolas'>  case 2:<o:p></o:p></span></p><p style='margin-left:.5in'><span style='font-family:Consolas'>    doSomething(2);<o:p></o:p></span></p><p style='margin-left:.5in'><span style='font-family:Consolas'>    break;<o:p></o:p></span></p><p style='margin-left:.5in'><span style='font-family:Consolas'><o:p> </o:p></span></p><p style='margin-left:.5in'><span style='font-family:Consolas'>  case 3:<o:p></o:p></span></p><p style='margin-left:.5in'><span style='font-family:Consolas'>  {<o:p></o:p></span></p><p style='margin-left:.5in'><span style='font-family:Consolas'>    int j = 3;<o:p></o:p></span></p><p style='margin-left:.5in'><span style='font-family:Consolas'>    doSomething(j);<o:p></o:p></span></p><p style='margin-left:.5in'><span style='font-family:Consolas'>    break;<o:p></o:p></span></p><p style='margin-left:.5in'><span style='font-family:Consolas'>  }<o:p></o:p></span></p><p style='margin-left:.5in'><span style='font-family:Consolas'><o:p> </o:p></span></p><p style='margin-left:.5in'><span style='font-family:Consolas'>  default:<o:p></o:p></span></p><p style='margin-left:.5in'><span style='font-family:Consolas'>    doSomething(0);<o:p></o:p></span></p><p style='margin-left:.5in'><span style='font-family:Consolas'>    break;<o:p></o:p></span></p><p style='margin-left:.5in'><span style='font-family:Consolas'>}<o:p></o:p></span></p><p><o:p> </o:p></p><p class=MsoListParagraphCxSpFirst style='text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span style='font-family:Symbol'><span style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'>         </span></span></span><![endif]>When a ‘case’ or ‘default’ contains a declaration and therefore needs a compound statement, all statements under this label should be placed inside the compound statement, including ‘break’ or ‘// Fallthrough’.</p><p class=MsoListParagraphCxSpLast style='text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span style='font-family:Symbol'><span style='mso-list:Ignore'>·<span style='font:7.0pt "Times New Roman"'>         </span></span></span><![endif]>When any ‘case’ or ‘default’ label is using a compound statement, all ‘case’ and ‘default’ labels 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 class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>A ‘switch’ statement without compound statements may still be formatted in the current way, i.e. no extra indentation for ‘case’ and ‘default’.<o:p></o:p></p><p><o:p> </o:p></p><p>However, if we allow a mix of compound and non-compound labels, we should also permit (but not require) 2-space indented ‘case’ and ‘default’ labels even if none of the labels contains a compound statement. Otherwise, the addition or removal of a label with compound statement would require indenting or unindenting the entire switch statement, which is unnecessary.</p><p><o:p> </o:p></p><p>Yours, Junxiao</p><p><o:p> </o:p></p><div style='mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p style='border:none;padding:0in'><br><b>From: </b>Wentao Shang<br><b>Sent: </b>Wednesday, August 12, 2015 16:01<br><b>To: </b>Junxiao Shi<br><b>Cc: </b>;Eric Newberry<br><b>Subject: </b>Re: [Nfd-dev] code-style: switch with compound statement</p></div><p class=MsoNormal><span style='font-family:"Times New Roman",serif'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:"Times New Roman",serif'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman",serif'><br><br>On Wednesday, August 12, 2015, Junxiao Shi <<a href="mailto:shijunxiao@email.arizona.edu">shijunxiao@email.arizona.edu</a>> wrote:</span><span style='font-size:12.0pt;font-family:"Times New Roman",serif'><o:p></o:p></span></p><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt'><div><div><p><span style='font-family:Symbol'>·</span><span style='font-size:7.0pt'>         </span>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><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman",serif'>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.<o:p></o:p></span></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt'><div><div><p><span style='font-family:Symbol'>·</span><span style='font-size:7.0pt'>         </span>‘break’ and ‘// Fallthrough’ should be placed inside compound statements.</p></div></div></blockquote><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman",serif'>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.)<o:p></o:p></span></p></div></body></html>