<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=""><div><blockquote type="cite" class=""><div class="">On Dec 11, 2015, at 6:11 PM, Liam Butler-Lawrence via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Bumping this up. If anyone on the Apple team (or anybody else!) has any feedback that would be much appreciated. Also, I’d be happy to write up an official proposal if requested- the suggested guideline was to have a thorough discussion first, which this really hasn’t had yet.</div></div></div></blockquote><div><br class=""></div>I’m sorry, I’ve had a lot of other significant designs to look at recently, and I’ve been rate-limiting them so I don’t neglect all the other work on my plate. :) &nbsp;I’ll try to take a look at this sometime next week; is that alright?</div><div><br class=""></div><div>John.</div><div><br class=""><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=""><br class=""></div><div class="">Thanks!</div><div class="">Liam</div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 7, 2015, at 11:30 PM, Liam Butler-Lawrence via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="">Hi Kame,</div><div class=""><br class=""></div><div class="">Thanks for the work you put into this! I’ll give my thoughts on each proposed syntax:</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(207, 135, 36);">// First syntax:</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(53, 86, 138);"><span class="">&nbsp; &nbsp;&nbsp;</span>guard<span class="">&nbsp;</span>let</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(207, 135, 36);"><span class="">&nbsp; &nbsp; &nbsp; &nbsp; bar = bar,&nbsp;&nbsp;</span>// Has to be non-nil</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(207, 135, 36);"><span class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span class="" style="color: rgb(53, 86, 138);">try</span><span class="">&nbsp;foo(</span><span class="" style="color: rgb(232, 35, 0);">"Hello"</span><span class="">), &nbsp;&nbsp;</span>// Has to not throw an error</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp; x =&nbsp;<span class="" style="color: rgb(53, 86, 138);">try</span>&nbsp;qux()</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">where</span>&nbsp;bar &gt;&nbsp;<span class="" style="color: rgb(53, 86, 138);">10</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(207, 135, 36);"><span class="">&nbsp; &nbsp;&nbsp;</span><span class="" style="color: rgb(53, 86, 138);">else</span><span class="">&nbsp;{&nbsp; &nbsp;&nbsp;</span>// Has to not throw an error</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(207, 135, 36);"><span class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span class="" style="color: rgb(53, 86, 138);">return</span><span class="">&nbsp;&nbsp;</span>// Bar or baz was nil</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; }&nbsp;<span class="" style="color: rgb(53, 86, 138);">catch</span>&nbsp;Error.Some {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(207, 135, 36);"><span class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span class="" style="color: rgb(53, 86, 138);">return</span><span class="">&nbsp;&nbsp;</span>// Some Error occured</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; }&nbsp;<span class="" style="color: rgb(53, 86, 138);">catch</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(207, 135, 36);"><span class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span class="" style="color: rgb(53, 86, 138);">return</span><span class="">&nbsp;&nbsp;</span>// Another Error occured</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(207, 135, 36);"><span class="">&nbsp; &nbsp;&nbsp;</span>// `else` has to be there for optional, `catch` for errors</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">guard</span>&nbsp;<span class="" style="color: rgb(53, 86, 138);">try</span>&nbsp;foo(<span class="" style="color: rgb(232, 35, 0);">"Hello"</span>),&nbsp;<span class="" style="color: rgb(53, 86, 138);">let</span>&nbsp;x =&nbsp;<span class="" style="color: rgb(53, 86, 138);">try</span>&nbsp;qux()&nbsp;<span class="" style="color: rgb(53, 86, 138);">where</span>&nbsp;x &lt;&nbsp;<span class="" style="color: rgb(53, 86, 138);">10</span>&nbsp;<span class="" style="color: rgb(53, 86, 138);">catch</span>&nbsp;Error.Some {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">return</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; }&nbsp;<span class="" style="color: rgb(53, 86, 138);">catch</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">return</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(207, 135, 36);"><span class="">&nbsp; &nbsp;&nbsp;</span>// Results can be ignored; catch can be on new line</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(53, 86, 138);"><span class="">&nbsp; &nbsp;&nbsp;</span>guard<span class="">&nbsp;</span>let</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">_</span>&nbsp;=&nbsp;<span class="" style="color: rgb(53, 86, 138);">try</span>&nbsp;foo(<span class="" style="color: rgb(232, 35, 0);">"Hello"</span>),</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">_</span>&nbsp;=&nbsp;<span class="" style="color: rgb(53, 86, 138);">try</span>&nbsp;qux()</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(207, 135, 36);"><span class="">&nbsp; &nbsp;&nbsp;</span><span class="" style="color: rgb(53, 86, 138);">catch</span><span class="">&nbsp;Error.Some {&nbsp;&nbsp;</span>// Not 100% beautiful</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">return</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; }&nbsp;<span class="" style="color: rgb(53, 86, 138);">catch</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">return</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; }</div></div></div></blockquote></div><div class=""><br class=""></div><div class="">This is comprehensive and seems (to me, anyway!) like it could definitely work. My only concern is that the similar-but-different syntaxes for the different optional/<span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">try</span>&nbsp;combinations could be a bit confusing. I see the following three unique syntaxes in your proposal:</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(53, 86, 138);"><span class="">&nbsp; &nbsp;&nbsp;</span>guard<span class="">&nbsp;</span>let x = y, try z(a) else { } catch E { }... catch { }</div></div></div></blockquote><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(53, 86, 138);"><span class="">&nbsp; &nbsp;&nbsp;</span>guard<span class="">&nbsp;let x =&nbsp;</span>try z(a) else { } catch E { }... catch { }</div></div></div></blockquote><div class=""><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(53, 86, 138);"><span class="">&nbsp; &nbsp;&nbsp;</span>guard<span class="">&nbsp;</span>try z(a) catch E { }... catch { }</div></div></div></blockquote><br class=""><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""></div></div></blockquote></div></div><div class="">That’s not even considering&nbsp;<span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">where</span>&nbsp;conditions, or chaining more than a single optional and&nbsp;<span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">try</span>&nbsp;together in a single&nbsp;<span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">guard</span>&nbsp;expression.&nbsp;</div><div class=""><br class=""></div><div class="">What if one wanted to put a&nbsp;<span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">try</span>&nbsp;clause before an optional? In that case, when is&nbsp;<span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">let</span>&nbsp;required to prefix an&nbsp;<span class="" style="font-family: Menlo;">unwrapped = optional&nbsp;</span>clause? Currently, it is only required at the beginning of the chain. If the chain starts with a&nbsp;<span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">try</span>, is&nbsp;<span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">let</span>&nbsp;still required first, or simply at the first instance of an&nbsp;<span class="" style="font-family: Menlo;">unwrapped = optional</span>, or not at all? The second option might look something like this:</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(53, 86, 138);"><span class="">&nbsp; &nbsp;&nbsp;</span>guard<span class="">&nbsp;</span>try z(a), let x = y, c = d else { } catch E { }... catch { }</div></div></div></blockquote><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""></div></div></blockquote></div><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(53, 86, 138);"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(53, 86, 138);"><span class="" style="font-family: Helvetica; font-size: 12px;">Note: I'm ignoring the possibility of&nbsp;</span>guard var<span class="" style="font-family: Helvetica; font-size: 12px;">… as&nbsp;</span><a href="https://github.com/apple/swift-evolution/blob/master/proposals/0003-remove-var-parameters-patterns.md" class="" style="font-family: Helvetica; font-size: 12px;">proposal 0003</a><span class="" style="font-family: Helvetica; font-size: 12px;">&nbsp;has already been accepted</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(53, 86, 138);"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(53, 86, 138);"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(53, 86, 138);"><span class="" style="font-family: Helvetica; font-size: 12px;">****</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(53, 86, 138);"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(53, 86, 138);"><br class=""></div></div></div></div><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class="" style="margin: 0px; line-height: normal;"><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="color: rgb(207, 135, 36);">&nbsp; &nbsp;&nbsp;</span><span class="" style="color: rgb(207, 135, 36);">// Second syntax, no error matching, my personal preference</span></div></div></div></blockquote><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">guard</span>&nbsp;<span class="" style="color: rgb(53, 86, 138);">try</span>&nbsp;foo(<span class="" style="color: rgb(232, 35, 0);">"Hello"</span>),&nbsp;<span class="" style="color: rgb(53, 86, 138);">let</span>&nbsp;x =&nbsp;<span class="" style="color: rgb(53, 86, 138);">try</span>&nbsp;qux()&nbsp;<span class="" style="color: rgb(53, 86, 138);">catch</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">switch</span>&nbsp;error {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">case</span>&nbsp;Error.Some:&nbsp;<span class="" style="color: rgb(53, 86, 138);">return</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(53, 86, 138);"><span class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span>default<span class="">:&nbsp;</span>return</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; }</div></div></div></blockquote><br class=""></div><div class="" style="margin: 0px; line-height: normal;">I like this a lot. However, I think going with this version would move this proposal from a medium-level syntax change (changing or adding an option for where errors are caught) to a fundamental change to the error handling-model (<i class="">how</i>&nbsp;errors are caught). Accepting that, we could go one step further and eliminate the boilerplate&nbsp;<span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">switch { }</span>:</div><div class="" style="margin: 0px; line-height: normal;"><br class=""></div><div class="" style="margin: 0px; line-height: normal;"><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">guard</span>&nbsp;<span class="" style="color: rgb(53, 86, 138);">try</span>&nbsp;foo(<span class="" style="color: rgb(232, 35, 0);">"Hello"</span>),&nbsp;<span class="" style="color: rgb(53, 86, 138);">let</span>&nbsp;x =&nbsp;<span class="" style="color: rgb(53, 86, 138);">try</span>&nbsp;qux()&nbsp;<span class="" style="color: rgb(53, 86, 138);">catch</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">case</span>&nbsp;Error.Some:&nbsp;<span class="" style="color: rgb(53, 86, 138);">return</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(53, 86, 138);"><span class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span>default<span class="">:&nbsp;</span>return</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; }</div></div></div></blockquote><br class=""></div><div class="" style="margin: 0px; line-height: normal;">This basically turns catch { } into a specialized switch statement. I don’t think this would cause any functionality issues, as&nbsp;<span class="" style="font-family: Menlo; font-size: 11px; color: rgb(53, 86, 138);">case</span><span class="" style="font-family: Menlo; font-size: 11px;">&nbsp;X:&nbsp;</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(53, 86, 138);">case</span><span class="" style="font-family: Menlo; font-size: 11px;">&nbsp;Y:&nbsp;</span><span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">default:&nbsp;</span>syntax already works in exactly the same manner as&nbsp;<span class="" style="font-family: Menlo; font-size: 11px; color: rgb(53, 86, 138);">catch X</span><span class="" style="font-family: Menlo; font-size: 11px;">&nbsp;{ }&nbsp;</span><span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">catch Y&nbsp;</span><span class="" style="font-family: Menlo; font-size: 11px;">{&nbsp;</span><span class="" style="font-family: Menlo; font-size: 11px;">}&nbsp;</span><span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">catch</span><span class="" style="font-family: Menlo; font-size: 11px;">&nbsp;{ }</span>. Even&nbsp;<span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">where</span>&nbsp;conditions that can currently be applied to&nbsp;<span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">catch</span>&nbsp;should work just fine as&nbsp;<span class="" style="font-family: Menlo; font-size: 11px; color: rgb(53, 86, 138);">case</span><span class="" style="font-family: Menlo; font-size: 11px;">&nbsp;X&nbsp;</span><span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">where&nbsp;</span><span class="" style="font-family: Menlo; font-size: 11px;">X.</span>&nbsp;The only thing to really consider would be the syntax when what was thrown is irrelevant. You proposed this:</div><div class="" style="margin: 0px; line-height: normal;"><br class=""></div><div class="" style="margin: 0px; line-height: normal;"><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">guard</span>&nbsp;<span class="" style="color: rgb(53, 86, 138);">let</span>&nbsp;bar = bar,&nbsp;<span class="" style="color: rgb(53, 86, 138);">let</span>&nbsp;<span class="" style="color: rgb(53, 86, 138);">_</span>&nbsp;=&nbsp;<span class="" style="color: rgb(53, 86, 138);">try</span>&nbsp;qux()&nbsp;<span class="" style="color: rgb(53, 86, 138);">where</span>&nbsp;baz ==&nbsp;<span class="" style="color: rgb(53, 86, 138);">true</span>&nbsp;<span class="" style="color: rgb(53, 86, 138);">else</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">return</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; }&nbsp;<span class="" style="color: rgb(53, 86, 138);">catch</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">return</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; }</div></div></div></blockquote></div><div class="" style="margin: 0px; line-height: normal;"><br class=""></div><div class="" style="margin: 0px; line-height: normal;">Unfortunately, this seems incongruent with my idea of turning&nbsp;<span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">catch</span>&nbsp;into an implied&nbsp;<span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">switch</span>&nbsp;statement. Perhaps</div><div class="" style="margin: 0px; line-height: normal;"><br class=""></div><div class="" style="margin: 0px; line-height: normal;"><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">guard</span>&nbsp;<span class="" style="color: rgb(53, 86, 138);">let</span>&nbsp;bar = bar,&nbsp;<span class="" style="color: rgb(53, 86, 138);">let</span>&nbsp;<span class="" style="color: rgb(53, 86, 138);">_</span>&nbsp;=&nbsp;<span class="" style="color: rgb(53, 86, 138);">try</span>&nbsp;qux()&nbsp;<span class="" style="color: rgb(53, 86, 138);">where</span>&nbsp;baz ==&nbsp;<span class="" style="color: rgb(53, 86, 138);">true</span>&nbsp;<span class="" style="color: rgb(53, 86, 138);">else</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">return</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; }&nbsp;<span class="" style="color: rgb(53, 86, 138);">catch</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp; default:&nbsp;<span class="" style="color: rgb(53, 86, 138);">return</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; }</div></div></div></blockquote><br class=""></div><div class="" style="margin: 0px; line-height: normal;">though I can’t say I love this approach.</div><div class="" style="margin: 0px; line-height: normal;"><br class=""></div><div class="" style="margin: 0px; line-height: normal;">Of course, most of the considerations I mentioned from syntax #1 (regarding clarity in optional/try chaining) apply to both versions of #2 as well. That said, putting all the&nbsp;<span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">catch</span>&nbsp;“cases" in one&nbsp;<span class="" style="font-family: Menlo; font-size: 11px;">{&nbsp;</span><span class="" style="font-family: Menlo; font-size: 11px;">}</span>&nbsp;block is far more concise and could possibly make those considerations less of an issue.</div><div class="" style="margin: 0px; line-height: normal;"><br class=""></div><div class="" style="margin: 0px; line-height: normal;"><br class=""></div><div class="" style="margin: 0px; line-height: normal;">****</div><div class="" style="margin: 0px; line-height: normal;"><br class=""></div><div class="" style="margin: 0px; line-height: normal;"><br class=""></div><div class="" style="margin: 0px; line-height: normal;"><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(207, 135, 36);"><span class="">&nbsp; &nbsp;&nbsp;</span>// Third syntax, `else` for everything, implicit `error` variable when a `try` was used in the guard</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">guard</span>&nbsp;<span class="" style="color: rgb(53, 86, 138);">try</span>&nbsp;foo(<span class="" style="color: rgb(232, 35, 0);">"Hello"</span>)&nbsp;<span class="" style="color: rgb(53, 86, 138);">else</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">switch</span>&nbsp;error {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">case</span>&nbsp;Error.Some:&nbsp;<span class="" style="color: rgb(53, 86, 138);">return</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(53, 86, 138);"><span class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span>default<span class="">:&nbsp;</span>return</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; }</div></div></div></blockquote><br class=""></div><div class="" style="margin: 0px; line-height: normal;">I think removing&nbsp;<span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">catch</span>&nbsp;is a bad idea. Not just because almost every other language uses it for exception/error handling, but because it is a natural parallel to&nbsp;<font color="#35568a" face="Menlo" class=""><span class="" style="font-size: 11px;">throw</span></font>. It makes sense on an intuitive level, and I don’t think we should mess with that. Not to mention the&nbsp;<span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">else</span>&nbsp;block could easily get very messy very fast.&nbsp;</div><div class="" style="margin: 0px; line-height: normal;"><br class=""></div><div class="" style="margin: 0px; line-height: normal;">Thanks again! I appreciate your comments on my suggestions as well :)</div><div class="" style="margin: 0px; line-height: normal;"><br class=""></div><div class="" style="margin: 0px; line-height: normal;">Liam</div></div></div></div></div><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><blockquote type="cite" class=""><div class="">On Dec 7, 2015, at 2:35 PM, Kametrixom Tikara &lt;<a href="mailto:kametrixom@icloud.com" class="">kametrixom@icloud.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="">Hi Liam, this is how I imagine it working, I proposed three slightly different syntax rules:</div><div class=""><br class=""></div><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="color: rgb(53, 86, 138);">enum</span>&nbsp;Error :&nbsp;<span class="" style="color: rgb(195, 89, 0);">ErrorType</span>&nbsp;{&nbsp;<span class="" style="color: rgb(53, 86, 138);">case</span>&nbsp;Some }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="color: rgb(53, 86, 138);">func</span>&nbsp;test(bar:&nbsp;<span class="" style="color: rgb(195, 89, 0);">Int</span>?, baz:&nbsp;<span class="" style="color: rgb(195, 89, 0);">Bool</span>?, foo:&nbsp;<span class="" style="color: rgb(195, 89, 0);">String</span>&nbsp;<span class="" style="color: rgb(53, 86, 138);">throws</span>&nbsp;-&gt;&nbsp;<span class="" style="color: rgb(195, 89, 0);">Void</span>, qux: ()&nbsp;<span class="" style="color: rgb(53, 86, 138);">throws</span>&nbsp;-&gt;&nbsp;<span class="" style="color: rgb(195, 89, 0);">Double</span>) {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(207, 135, 36);"><span class="">&nbsp; &nbsp;&nbsp;</span>// Currently possible:</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">do</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">try</span>&nbsp;foo(<span class="" style="color: rgb(232, 35, 0);">"Hello"</span>)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">let</span>&nbsp;x =&nbsp;<span class="" style="color: rgb(53, 86, 138);">try</span>&nbsp;qux()</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; }&nbsp;<span class="" style="color: rgb(53, 86, 138);">catch</span>&nbsp;Error.Some {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(88, 126, 168);">print</span>(<span class="" style="color: rgb(232, 35, 0);">"Error!"</span>)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; }&nbsp;<span class="" style="color: rgb(53, 86, 138);">catch</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(88, 126, 168);">print</span>(<span class="" style="color: rgb(232, 35, 0);">"Error!"</span>)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(207, 135, 36);"><span class="">&nbsp; &nbsp;&nbsp;</span>// First syntax:</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(53, 86, 138);"><span class="">&nbsp; &nbsp;&nbsp;</span>guard<span class="">&nbsp;</span>let</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(207, 135, 36);"><span class="">&nbsp; &nbsp; &nbsp; &nbsp; bar = bar,&nbsp;&nbsp;</span>// Has to be non-nil</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(207, 135, 36);"><span class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span class="" style="color: rgb(53, 86, 138);">try</span><span class="">&nbsp;foo(</span><span class="" style="color: rgb(232, 35, 0);">"Hello"</span><span class="">), &nbsp;&nbsp;</span>// Has to not throw an error</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp; x =&nbsp;<span class="" style="color: rgb(53, 86, 138);">try</span>&nbsp;qux()</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">where</span>&nbsp;bar &gt;&nbsp;<span class="" style="color: rgb(53, 86, 138);">10</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(207, 135, 36);"><span class="">&nbsp; &nbsp;&nbsp;</span><span class="" style="color: rgb(53, 86, 138);">else</span><span class="">&nbsp;{&nbsp; &nbsp;&nbsp;</span>// Has to not throw an error</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(207, 135, 36);"><span class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span class="" style="color: rgb(53, 86, 138);">return</span><span class="">&nbsp;&nbsp;</span>// Bar or baz was nil</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; }&nbsp;<span class="" style="color: rgb(53, 86, 138);">catch</span>&nbsp;Error.Some {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(207, 135, 36);"><span class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span class="" style="color: rgb(53, 86, 138);">return</span><span class="">&nbsp;&nbsp;</span>// Some Error occured</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; }&nbsp;<span class="" style="color: rgb(53, 86, 138);">catch</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(207, 135, 36);"><span class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span class="" style="color: rgb(53, 86, 138);">return</span><span class="">&nbsp;&nbsp;</span>// Another Error occured</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(207, 135, 36);"><span class="">&nbsp; &nbsp;&nbsp;</span>// `else` has to be there for optional, `catch` for errors</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">guard</span>&nbsp;<span class="" style="color: rgb(53, 86, 138);">try</span>&nbsp;foo(<span class="" style="color: rgb(232, 35, 0);">"Hello"</span>),&nbsp;<span class="" style="color: rgb(53, 86, 138);">let</span>&nbsp;x =&nbsp;<span class="" style="color: rgb(53, 86, 138);">try</span>&nbsp;qux()&nbsp;<span class="" style="color: rgb(53, 86, 138);">where</span>&nbsp;x &lt;&nbsp;<span class="" style="color: rgb(53, 86, 138);">10</span>&nbsp;<span class="" style="color: rgb(53, 86, 138);">catch</span>&nbsp;Error.Some {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">return</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; }&nbsp;<span class="" style="color: rgb(53, 86, 138);">catch</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">return</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(207, 135, 36);"><span class="">&nbsp; &nbsp;&nbsp;</span>// Results can be ignored; catch can be on new line</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(53, 86, 138);"><span class="">&nbsp; &nbsp;&nbsp;</span>guard<span class="">&nbsp;</span>let</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">_</span>&nbsp;=&nbsp;<span class="" style="color: rgb(53, 86, 138);">try</span>&nbsp;foo(<span class="" style="color: rgb(232, 35, 0);">"Hello"</span>),</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">_</span>&nbsp;=&nbsp;<span class="" style="color: rgb(53, 86, 138);">try</span>&nbsp;qux()</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(207, 135, 36);"><span class="">&nbsp; &nbsp;&nbsp;</span><span class="" style="color: rgb(53, 86, 138);">catch</span><span class="">&nbsp;Error.Some {&nbsp;&nbsp;</span>// Not 100% beautiful</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">return</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; }&nbsp;<span class="" style="color: rgb(53, 86, 138);">catch</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">return</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(207, 135, 36);"><span class="">&nbsp; &nbsp;&nbsp;</span>// Second syntax, no error matching, my personal preference</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">guard</span>&nbsp;<span class="" style="color: rgb(53, 86, 138);">try</span>&nbsp;foo(<span class="" style="color: rgb(232, 35, 0);">"Hello"</span>),&nbsp;<span class="" style="color: rgb(53, 86, 138);">let</span>&nbsp;x =&nbsp;<span class="" style="color: rgb(53, 86, 138);">try</span>&nbsp;qux()&nbsp;<span class="" style="color: rgb(53, 86, 138);">catch</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">switch</span>&nbsp;error {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">case</span>&nbsp;Error.Some:&nbsp;<span class="" style="color: rgb(53, 86, 138);">return</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(53, 86, 138);"><span class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span>default<span class="">:&nbsp;</span>return</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">guard</span>&nbsp;<span class="" style="color: rgb(53, 86, 138);">let</span>&nbsp;bar = bar,&nbsp;<span class="" style="color: rgb(53, 86, 138);">let</span>&nbsp;<span class="" style="color: rgb(53, 86, 138);">_</span>&nbsp;=&nbsp;<span class="" style="color: rgb(53, 86, 138);">try</span>&nbsp;qux()&nbsp;<span class="" style="color: rgb(53, 86, 138);">where</span>&nbsp;baz ==&nbsp;<span class="" style="color: rgb(53, 86, 138);">true</span>&nbsp;<span class="" style="color: rgb(53, 86, 138);">else</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">return</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; }&nbsp;<span class="" style="color: rgb(53, 86, 138);">catch</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">return</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(207, 135, 36);"><span class="">&nbsp; &nbsp;&nbsp;</span>// Third syntax, `else` for everything, implicit `error` variable when a `try` was used in the guard</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">guard</span>&nbsp;<span class="" style="color: rgb(53, 86, 138);">try</span>&nbsp;foo(<span class="" style="color: rgb(232, 35, 0);">"Hello"</span>)&nbsp;<span class="" style="color: rgb(53, 86, 138);">else</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">switch</span>&nbsp;error {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">case</span>&nbsp;Error.Some:&nbsp;<span class="" style="color: rgb(53, 86, 138);">return</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(53, 86, 138);"><span class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span>default<span class="">:&nbsp;</span>return</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">}</div></div><div class=""><br class=""></div><div class="">I think this feels right at home in Swift, `guard` indicating that some condition has to be met or else exit the scope. This syntax</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><div class="" style="margin: 0px; line-height: normal;">let result =&nbsp;<span class="" style="color: rgb(53, 86, 138);">try</span>&nbsp;test()&nbsp;<span class="" style="color: rgb(53, 86, 138);">catch</span>&nbsp;SomeError.SomeCase {</div><div class="" style="margin: 0px; line-height: normal; min-height: 14px;">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; line-height: normal; color: rgb(53, 86, 138);"><span class="">}&nbsp;</span>catch<span class="">&nbsp;{</span></div><div class="" style="margin: 0px; line-height: normal; min-height: 14px;">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; line-height: normal;">}</div></div></div></div></blockquote></div></div></blockquote><br class=""></div><div class="">you proposed doesn’t make it really clear that the scope has to be exited but I like it nonetheless. This also is in the same spirit as the recent discussion on making `if else`, `switch case` and such work as expression.</div><div class=""><br class=""></div><div class="">– Kame</div><div class=""><br class=""></div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 07 Dec 2015, at 18:40, Liam Butler-Lawrence &lt;<a href="mailto:liamdunn@me.com" class="">liamdunn@me.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="">Hey Kametrixom,</div><div class=""><br class=""></div><div class="">Thanks for the feedback! I agree that the proposed syntax needs improvement.</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><div class="" style="margin: 0px; line-height: normal;"><span class="" style="color: rgb(53, 86, 138);">guard</span>&nbsp;<span class="" style="color: rgb(53, 86, 138);">let</span>&nbsp;unwrapped = optional, result =&nbsp;<span class="" style="color: rgb(53, 86, 138);">try</span>&nbsp;test()&nbsp;<span class="" style="color: rgb(53, 86, 138);">else</span>&nbsp;{</div><div class="" style="margin: 0px; line-height: normal; min-height: 14px;">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; line-height: normal;">}&nbsp;<span class="" style="color: rgb(53, 86, 138);">catch</span>&nbsp;SomeError.SomeCase {</div><div class="" style="margin: 0px; line-height: normal; min-height: 14px;">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; line-height: normal; color: rgb(53, 86, 138);"><span class="">}&nbsp;</span>catch<span class="">&nbsp;{</span></div><div class="" style="margin: 0px; line-height: normal; min-height: 14px;">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; line-height: normal;">}</div></div></div></div></blockquote></div><div class=""><br class=""></div><div class="">I like this example, but it seems rather specific. Are you just using the &nbsp;<span class="" style="font-family: Menlo; color: rgb(53, 86, 138);">guard</span><span class="" style="font-family: Menlo;">&nbsp;</span><span class="" style="font-family: Menlo; color: rgb(53, 86, 138);">let</span><span class="" style="font-family: Menlo;">&nbsp;unwrapped = optional&nbsp;</span>to show how&nbsp;<i class="">guard let</i>&nbsp;and the&nbsp;<i class="">catch</i>&nbsp;block could be used together, or suggesting that guard let should be required for this functionality? If the latter, how would we handle throwing functions that don’t return a value?</div><div class=""><br class=""></div><div class="">I’m fine with removing the enclosing catch { } from my original suggestion; perhaps something like this? My only concern with this is that it’s slightly confusing to have the first&nbsp;<i class="">catch X</i>&nbsp;on the same line as the&nbsp;<i class="">try</i>&nbsp;call.</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><div class="" style="margin: 0px; line-height: normal;">let result =&nbsp;<span class="" style="color: rgb(53, 86, 138);">try</span>&nbsp;test()&nbsp;<span class="" style="color: rgb(53, 86, 138);">catch</span>&nbsp;SomeError.SomeCase {</div><div class="" style="margin: 0px; line-height: normal; min-height: 14px;">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; line-height: normal; color: rgb(53, 86, 138);"><span class="">}&nbsp;</span>catch<span class="">&nbsp;{</span></div><div class="" style="margin: 0px; line-height: normal; min-height: 14px;">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; line-height: normal;">}</div></div></div></div></blockquote></div><div class=""><br class=""></div><div class="">Also, regarding the new syntax being redundant:</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><span class="" style="color: rgb(53, 86, 138);">let</span>&nbsp;coordinator =&nbsp;<span class="" style="color: rgb(195, 89, 0);">NSPersistentStoreCoordinator</span>(managedObjectModel: managedObjectModel)</div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><span class="" style="color: rgb(53, 86, 138);">do</span>&nbsp;{</div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">let</span>&nbsp;documentsDirectoryURL =&nbsp;<span class="" style="color: rgb(53, 86, 138);">try</span>&nbsp;<span class="" style="color: rgb(195, 89, 0);">NSFileManager</span>.<span class="" style="color: rgb(88, 126, 168);">defaultManager</span>().<span class="" style="color: rgb(88, 126, 168);">URLForDirectory</span>(.<span class="" style="color: rgb(88, 126, 168);">DocumentDirectory</span>, inDomain: .UserDomainMask, appropriateForURL:&nbsp;<span class="" style="color: rgb(53, 86, 138);">nil</span>, create:&nbsp;<span class="" style="color: rgb(53, 86, 138);">false</span>)</div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">let</span>&nbsp;persistentStoreFileName =&nbsp;<span class="" style="color: rgb(232, 35, 0);">"CoreDataStore.sqlite"</span></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">let</span>&nbsp;persistentStoreURL = documentsDirectoryURL.<span class="" style="color: rgb(88, 126, 168);">URLByAppendingPathComponent</span>(persistentStoreFileName)</div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(53, 86, 138);">try</span>&nbsp;<span class="" style="color: rgb(88, 126, 168);">coordinator</span>.addPersistentStoreWithType(<span class="" style="color: rgb(88, 126, 168);">NSSQLiteStoreType</span>, configuration:&nbsp;<span class="" style="color: rgb(53, 86, 138);">nil</span>, URL: persistentStoreURL, options:&nbsp;<span class="" style="color: rgb(53, 86, 138);">nil</span>)</div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;">}&nbsp;<span class="" style="color: rgb(53, 86, 138);">catch</span>&nbsp;MyError.Case1 {</div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;">}&nbsp;<span class="" style="color: rgb(53, 86, 138);">catch</span>&nbsp;MyError.Case2 {</div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;">}&nbsp;<span class="" style="color: rgb(53, 86, 138);">catch</span>&nbsp;MyError.Case3 {</div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;">}&nbsp;<span class="" style="color: rgb(53, 86, 138);">catch</span>&nbsp;AnotherError.Case1 {</div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;">}&nbsp;<span class="" style="color: rgb(53, 86, 138);">catch</span>&nbsp;AnotherError.Case2 {</div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;">}&nbsp;<span class="" style="color: rgb(53, 86, 138);">catch</span>&nbsp;AnotherError.Case3 {</div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo; color: rgb(53, 86, 138);"><span class="">}&nbsp;</span>catch<span class="">&nbsp;{</span></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;">}</div></div></div></blockquote><br class=""></div><div class="">Thanks for pointing out this possibility. However, this code makes it even harder to decipher where MyError will be thrown from. How about AnotherError– which function threw that? No way to know. In certain cases that may not be an issue, but what if the error handling code presented a UI error? I might want to know more than just what the error is, but the context in which it was generated as well. Putting all the catch blocks at the end directly impacts readability.</div><div class=""><br class=""></div><div class="">As an extension of this issue, suppose that both throwing functions threw the same kind of error. If I want to&nbsp;use a different response based on which function call actually threw the error, I simply can’t do that using this method.</div><div class=""><br class=""></div><div class="">Look forward to hearing your thoughts. Thanks again!</div><div class=""><br class=""></div><div class="">Liam</div></div></div></blockquote></div></div></div></blockquote></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=FWNXVkJEIvgBIPO6st52oaOhXz8A8SWiAS8uKJuLOYb6DwQgdgDk6wkkeCoPh4hJl4EnGP-2Bwvv2Po-2F1yChbZly7TzR0l-2FKhA8U5yGMKMLiTD77xmAqN8pqELfDI-2BVwZVzpadgagQJbykIe6zTxiQwDgKyvU07CtAqa-2FAIpECgvmljgB8g7uytm1PR-2FVPsFzeBtIDdfaqDbReqp-2FJQN1P9w-3D-3D" alt="" width="1" height="1" border="0" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""><span class="Apple-converted-space">&nbsp;</span></span><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">swift-evolution mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:swift-evolution@swift.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">swift-evolution@swift.org</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br class="">
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=hWKWvOREWCPT32eVzNXOV7yIWXgGOvlMtgjKbOieJnaFRSC7nLoknJ72gL7BwdXWQmat6CYhhjL-2BazfIZDzEoUpwencSKjaRAIY-2BSxeI2H3-2BjtqXFJap152w695GEuLmqq7dOXCzXbpbhUZmzVa8-2FKkkSkii1mXh0xRaloIa7OwtgXAC8BIIDNk2B1OiuhJ-2B4M0vZ8N4cKLMeHhIf7ynhvKy7rxh7ahF04P1Tm5oeaI-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
</div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>