<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On May 27, 2016, at 3:06 PM, Brandon Knope via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div></blockquote><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div class=""><br class=""></div><div class="">Second, I have really gotten use to not needing to use semicolons, and this proposal seems to use/require them in very common situations.</div><div class=""><br class=""></div><div class="">After shedding the requirement of semicolons from ObjC…now we will have to use them a lot again?</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Third, the format will look like this in most people’s code:</div><div class=""><pre style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; word-wrap: normal; padding: 16px; overflow: auto; background-color: rgb(247, 247, 247); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal;" class=""><span class="pl-k" style="color: rgb(167, 29, 93); box-sizing: border-box;">guard </span><font color="#333333" class="">x </font><span class="pl-k" style="color: rgb(167, 29, 93); box-sizing: border-box;">==</span><font color="#333333" class=""> </font><span class="pl-c1" style="color: rgb(0, 134, 179); box-sizing: border-box;">0</span><font color="#333333" class="">; </font><span class="pl-k" style="color: rgb(167, 29, 93); box-sizing: border-box;">let</span><font color="#333333" class=""> y </font><span class="pl-k" style="color: rgb(167, 29, 93); box-sizing: border-box;">=</span><font color="#333333" class=""> </font><span class="pl-k" style="color: rgb(167, 29, 93); box-sizing: border-box;">optional</span><font color="#333333" class="">; y </font><span class="pl-k" style="color: rgb(167, 29, 93); box-sizing: border-box;">==</span><font color="#333333" class=""> </font><span class="pl-c1" style="color: rgb(0, 134, 179); box-sizing: border-box;">2</span><font color="#333333" class=""> </font><span class="pl-k" style="color: rgb(167, 29, 93); box-sizing: border-box;">else</span><font color="#333333" class=""> {&nbsp; //can the third bool condition even refer to y? Is it still in scope?
</font><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);"><span class="Apple-tab-span">        </span>...</span><span style="color: rgb(51, 51, 51);" class=""> 
</span><span style="color: rgb(51, 51, 51);" class="">}</span></pre><div class="">(in the above example, <b class="">y == 2</b>&nbsp;is related to the optional that precedes it. Now it looks like a distinct statement)</div></div><div class=""><br class=""></div><div class="">compared to</div><div class=""><br class=""></div><div class=""><pre style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; word-wrap: normal; padding: 16px; overflow: auto; background-color: rgb(247, 247, 247); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal; color: rgb(51, 51, 51);" class=""><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">guard</span> x <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">==</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">0</span>, <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> y <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=&nbsp;</span>someOptional <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">where</span> y <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">==</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">2</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">else</span> { 
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);"><span class="Apple-tab-span" style="white-space:pre">        </span>...</span> 
}</pre><div class=""><br class=""></div></div><div class=""><br class=""></div><div class="">To my eyes: the old way reads more naturally and looks less heavy. I think it keeps its expressiveness and also keeps it somewhat poetic.</div></div></div></div></blockquote><div><br class=""></div><div>This proposal serves the grammar, enabling it to simplify, &nbsp;the compiler to avoid errors, and the developer to intermingle tests more naturally, as you would in processing JSON without having to nest or sequence separate guard statements. A main goal is differentiating the commas between conditions and in binding conditions, as you ask about below</div><div><br class=""></div><div>I don't think it's practical to use a second braced scope:</div><div><br class=""></div><div>guard {</div><div>&nbsp; &nbsp;condition</div><div>&nbsp; &nbsp;condition</div><div>&nbsp; &nbsp;condition</div><div>} else {</div><div>&nbsp; &nbsp;leave scope</div><div>}</div><div><br class=""></div><div>This would be confusing to anyone doing conditional binding for use in the top level scope; the bindings would "escape" the braces. Using semicolons establishes a balance between separating different kinds of conditions and allowing comma-delineated multiple bindings.</div><div><br class=""></div><div>Current state:</div><div><br class=""></div><div>* Confusing, complicated, organically grown grammar</div><div>* Inability to use independently standing Boolean assertions after the first (except for one outlier availability case)</div><div><br class=""></div><div>Proposed state:</div><div><br class=""></div><div>* Very simple grammar</div><div>* Developer-directed ordering of binding, availability, Boolean assertions, cases, used in the order they're consumed</div><div>* Slightly uglier</div><div><br class=""></div><div>The cost for this is a separator between conditions</div><div><br class=""></div><blockquote type="cite" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div class="">Also, can someone refer me to an example of this statement: "<span class="" style="color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">This proposal resolves this problem by retaining commas as separators within clauses (as used elsewhere in Swift) and introducing semicolons to separate distinct kinds of clauses (which aligns with the rest of the Swift language)</span><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol" size="3" class="">”</font></div></div></div></blockquote><div><br class=""></div><div><pre style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; word-wrap: normal; padding: 16px; overflow: auto; background-color: rgb(247, 247, 247); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal; color: rgb(51, 51, 51);" class=""><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">guard</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> x <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> opt1, y <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> opt2, z <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> opt3; booleanAssertion <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">else</span> { }</pre><div class=""><br class=""></div></div><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div class=""><span style="color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);" class=""><br class=""></span></div><div class=""><span style="background-color: rgb(255, 255, 255);" class=""><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol" size="3" class="">I rarely see any&nbsp;semicolons after the removal of C loops. So if someone could put me to where this is used elsewhere in Swift, please do!</font></span></div></div></div></div></blockquote><br class=""></div><div>Using semicolons brings conditions in-line with how semicolons are used as separators elsewhere in the Swift grammar.</div><div><br class=""></div><div>-- Erica</div><div><br class=""></div><br class=""></body></html>