<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Hi John,</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">Sounds great. I appreciate the response!</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">Liam<br><br>Sent from my iPhone</div><div><br>On Dec 11, 2015, at 9:39 PM, John McCall <<a href="mailto:rjmccall@apple.com">rjmccall@apple.com</a>> wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=utf-8"><div><blockquote type="cite" class=""><div class="">On Dec 11, 2015, at 6:11 PM, Liam Butler-Lawrence via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> 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. :) 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 <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> 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=""> </span>guard<span class=""> </span>let</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(207, 135, 36);"><span class=""> bar = bar, </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=""> </span><span class="" style="color: rgb(53, 86, 138);">try</span><span class=""> foo(</span><span class="" style="color: rgb(232, 35, 0);">"Hello"</span><span class="">), </span>// Has to not throw an error</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> x = <span class="" style="color: rgb(53, 86, 138);">try</span> qux()</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <span class="" style="color: rgb(53, 86, 138);">where</span> bar > <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=""> </span><span class="" style="color: rgb(53, 86, 138);">else</span><span class=""> { </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=""> </span><span class="" style="color: rgb(53, 86, 138);">return</span><span class=""> </span>// Bar or baz was nil</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> } <span class="" style="color: rgb(53, 86, 138);">catch</span> Error.Some {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(207, 135, 36);"><span class=""> </span><span class="" style="color: rgb(53, 86, 138);">return</span><span class=""> </span>// Some Error occured</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> } <span class="" style="color: rgb(53, 86, 138);">catch</span> {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(207, 135, 36);"><span class=""> </span><span class="" style="color: rgb(53, 86, 138);">return</span><span class=""> </span>// Another Error occured</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"> <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=""> </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;"> <span class="" style="color: rgb(53, 86, 138);">guard</span> <span class="" style="color: rgb(53, 86, 138);">try</span> foo(<span class="" style="color: rgb(232, 35, 0);">"Hello"</span>), <span class="" style="color: rgb(53, 86, 138);">let</span> x = <span class="" style="color: rgb(53, 86, 138);">try</span> qux() <span class="" style="color: rgb(53, 86, 138);">where</span> x < <span class="" style="color: rgb(53, 86, 138);">10</span> <span class="" style="color: rgb(53, 86, 138);">catch</span> Error.Some {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <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;"> } <span class="" style="color: rgb(53, 86, 138);">catch</span> {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <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;"> }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"> <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=""> </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=""> </span>guard<span class=""> </span>let</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <span class="" style="color: rgb(53, 86, 138);">_</span> = <span class="" style="color: rgb(53, 86, 138);">try</span> 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;"> <span class="" style="color: rgb(53, 86, 138);">_</span> = <span class="" style="color: rgb(53, 86, 138);">try</span> qux()</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(207, 135, 36);"><span class=""> </span><span class="" style="color: rgb(53, 86, 138);">catch</span><span class=""> Error.Some { </span>// Not 100% beautiful</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <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;"> } <span class="" style="color: rgb(53, 86, 138);">catch</span> {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <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;"> }</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> 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=""> </span>guard<span class=""> </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=""> </span>guard<span class=""> let x = </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=""> </span>guard<span class=""> </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 <span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">where</span> conditions, or chaining more than a single optional and <span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">try</span> together in a single <span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">guard</span> expression. </div><div class=""><br class=""></div><div class="">What if one wanted to put a <span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">try</span> clause before an optional? In that case, when is <span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">let</span> required to prefix an <span class="" style="font-family: Menlo;">unwrapped = optional </span>clause? Currently, it is only required at the beginning of the chain. If the chain starts with a <span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">try</span>, is <span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">let</span> still required first, or simply at the first instance of an <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=""> </span>guard<span class=""> </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 </span>guard var<span class="" style="font-family: Helvetica; font-size: 12px;">… as </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;"> 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);"> </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;"> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <span class="" style="color: rgb(53, 86, 138);">guard</span> <span class="" style="color: rgb(53, 86, 138);">try</span> foo(<span class="" style="color: rgb(232, 35, 0);">"Hello"</span>), <span class="" style="color: rgb(53, 86, 138);">let</span> x = <span class="" style="color: rgb(53, 86, 138);">try</span> qux() <span class="" style="color: rgb(53, 86, 138);">catch</span> {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <span class="" style="color: rgb(53, 86, 138);">switch</span> error {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <span class="" style="color: rgb(53, 86, 138);">case</span> Error.Some: <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=""> </span>default<span class="">: </span>return</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> }</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> errors are caught). Accepting that, we could go one step further and eliminate the boilerplate <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;"> <span class="" style="color: rgb(53, 86, 138);">guard</span> <span class="" style="color: rgb(53, 86, 138);">try</span> foo(<span class="" style="color: rgb(232, 35, 0);">"Hello"</span>), <span class="" style="color: rgb(53, 86, 138);">let</span> x = <span class="" style="color: rgb(53, 86, 138);">try</span> qux() <span class="" style="color: rgb(53, 86, 138);">catch</span> {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <span class="" style="color: rgb(53, 86, 138);">case</span> Error.Some: <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=""> </span>default<span class="">: </span>return</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> }</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 <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;"> X: </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;"> Y: </span><span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">default: </span>syntax already works in exactly the same manner as <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;"> { } </span><span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">catch Y </span><span class="" style="font-family: Menlo; font-size: 11px;">{ </span><span class="" style="font-family: Menlo; font-size: 11px;">} </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;"> { }</span>. Even <span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">where</span> conditions that can currently be applied to <span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">catch</span> should work just fine as <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;"> X </span><span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">where </span><span class="" style="font-family: Menlo; font-size: 11px;">X.</span> 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;"> <span class="" style="color: rgb(53, 86, 138);">guard</span> <span class="" style="color: rgb(53, 86, 138);">let</span> bar = bar, <span class="" style="color: rgb(53, 86, 138);">let</span> <span class="" style="color: rgb(53, 86, 138);">_</span> = <span class="" style="color: rgb(53, 86, 138);">try</span> qux() <span class="" style="color: rgb(53, 86, 138);">where</span> baz == <span class="" style="color: rgb(53, 86, 138);">true</span> <span class="" style="color: rgb(53, 86, 138);">else</span> {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <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;"> } <span class="" style="color: rgb(53, 86, 138);">catch</span> {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <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;"> }</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 <span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">catch</span> into an implied <span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">switch</span> 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;"> <span class="" style="color: rgb(53, 86, 138);">guard</span> <span class="" style="color: rgb(53, 86, 138);">let</span> bar = bar, <span class="" style="color: rgb(53, 86, 138);">let</span> <span class="" style="color: rgb(53, 86, 138);">_</span> = <span class="" style="color: rgb(53, 86, 138);">try</span> qux() <span class="" style="color: rgb(53, 86, 138);">where</span> baz == <span class="" style="color: rgb(53, 86, 138);">true</span> <span class="" style="color: rgb(53, 86, 138);">else</span> {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <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;"> } <span class="" style="color: rgb(53, 86, 138);">catch</span> {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> default: <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;"> }</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 <span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">catch</span> “cases" in one <span class="" style="font-family: Menlo; font-size: 11px;">{ </span><span class="" style="font-family: Menlo; font-size: 11px;">}</span> 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=""> </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;"> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <span class="" style="color: rgb(53, 86, 138);">guard</span> <span class="" style="color: rgb(53, 86, 138);">try</span> foo(<span class="" style="color: rgb(232, 35, 0);">"Hello"</span>) <span class="" style="color: rgb(53, 86, 138);">else</span> {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <span class="" style="color: rgb(53, 86, 138);">switch</span> error {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <span class="" style="color: rgb(53, 86, 138);">case</span> Error.Some: <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=""> </span>default<span class="">: </span>return</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> }</div></div></div></blockquote><br class=""></div><div class="" style="margin: 0px; line-height: normal;">I think removing <span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">catch</span> 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 <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 <span class="" style="color: rgb(53, 86, 138); font-family: Menlo; font-size: 11px;">else</span> block could easily get very messy very fast. </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 <<a href="mailto:kametrixom@icloud.com" class="">kametrixom@icloud.com</a>> 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> Error : <span class="" style="color: rgb(195, 89, 0);">ErrorType</span> { <span class="" style="color: rgb(53, 86, 138);">case</span> 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> test(bar: <span class="" style="color: rgb(195, 89, 0);">Int</span>?, baz: <span class="" style="color: rgb(195, 89, 0);">Bool</span>?, foo: <span class="" style="color: rgb(195, 89, 0);">String</span> <span class="" style="color: rgb(53, 86, 138);">throws</span> -> <span class="" style="color: rgb(195, 89, 0);">Void</span>, qux: () <span class="" style="color: rgb(53, 86, 138);">throws</span> -> <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=""> </span>// Currently possible:</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <span class="" style="color: rgb(53, 86, 138);">do</span> {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <span class="" style="color: rgb(53, 86, 138);">try</span> 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;"> <span class="" style="color: rgb(53, 86, 138);">let</span> x = <span class="" style="color: rgb(53, 86, 138);">try</span> qux()</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> } <span class="" style="color: rgb(53, 86, 138);">catch</span> Error.Some {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <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;"> } <span class="" style="color: rgb(53, 86, 138);">catch</span> {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <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;"> }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"> <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=""> </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=""> </span>guard<span class=""> </span>let</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(207, 135, 36);"><span class=""> bar = bar, </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=""> </span><span class="" style="color: rgb(53, 86, 138);">try</span><span class=""> foo(</span><span class="" style="color: rgb(232, 35, 0);">"Hello"</span><span class="">), </span>// Has to not throw an error</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> x = <span class="" style="color: rgb(53, 86, 138);">try</span> qux()</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <span class="" style="color: rgb(53, 86, 138);">where</span> bar > <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=""> </span><span class="" style="color: rgb(53, 86, 138);">else</span><span class=""> { </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=""> </span><span class="" style="color: rgb(53, 86, 138);">return</span><span class=""> </span>// Bar or baz was nil</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> } <span class="" style="color: rgb(53, 86, 138);">catch</span> Error.Some {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(207, 135, 36);"><span class=""> </span><span class="" style="color: rgb(53, 86, 138);">return</span><span class=""> </span>// Some Error occured</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> } <span class="" style="color: rgb(53, 86, 138);">catch</span> {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(207, 135, 36);"><span class=""> </span><span class="" style="color: rgb(53, 86, 138);">return</span><span class=""> </span>// Another Error occured</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"> <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=""> </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;"> <span class="" style="color: rgb(53, 86, 138);">guard</span> <span class="" style="color: rgb(53, 86, 138);">try</span> foo(<span class="" style="color: rgb(232, 35, 0);">"Hello"</span>), <span class="" style="color: rgb(53, 86, 138);">let</span> x = <span class="" style="color: rgb(53, 86, 138);">try</span> qux() <span class="" style="color: rgb(53, 86, 138);">where</span> x < <span class="" style="color: rgb(53, 86, 138);">10</span> <span class="" style="color: rgb(53, 86, 138);">catch</span> Error.Some {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <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;"> } <span class="" style="color: rgb(53, 86, 138);">catch</span> {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <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;"> }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"> <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=""> </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=""> </span>guard<span class=""> </span>let</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <span class="" style="color: rgb(53, 86, 138);">_</span> = <span class="" style="color: rgb(53, 86, 138);">try</span> 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;"> <span class="" style="color: rgb(53, 86, 138);">_</span> = <span class="" style="color: rgb(53, 86, 138);">try</span> qux()</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(207, 135, 36);"><span class=""> </span><span class="" style="color: rgb(53, 86, 138);">catch</span><span class=""> Error.Some { </span>// Not 100% beautiful</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <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;"> } <span class="" style="color: rgb(53, 86, 138);">catch</span> {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <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;"> }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"> <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=""> </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;"> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <span class="" style="color: rgb(53, 86, 138);">guard</span> <span class="" style="color: rgb(53, 86, 138);">try</span> foo(<span class="" style="color: rgb(232, 35, 0);">"Hello"</span>), <span class="" style="color: rgb(53, 86, 138);">let</span> x = <span class="" style="color: rgb(53, 86, 138);">try</span> qux() <span class="" style="color: rgb(53, 86, 138);">catch</span> {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <span class="" style="color: rgb(53, 86, 138);">switch</span> error {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <span class="" style="color: rgb(53, 86, 138);">case</span> Error.Some: <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=""> </span>default<span class="">: </span>return</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <span class="" style="color: rgb(53, 86, 138);">guard</span> <span class="" style="color: rgb(53, 86, 138);">let</span> bar = bar, <span class="" style="color: rgb(53, 86, 138);">let</span> <span class="" style="color: rgb(53, 86, 138);">_</span> = <span class="" style="color: rgb(53, 86, 138);">try</span> qux() <span class="" style="color: rgb(53, 86, 138);">where</span> baz == <span class="" style="color: rgb(53, 86, 138);">true</span> <span class="" style="color: rgb(53, 86, 138);">else</span> {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <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;"> } <span class="" style="color: rgb(53, 86, 138);">catch</span> {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <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;"> }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"> <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=""> </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;"> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <span class="" style="color: rgb(53, 86, 138);">guard</span> <span class="" style="color: rgb(53, 86, 138);">try</span> foo(<span class="" style="color: rgb(232, 35, 0);">"Hello"</span>) <span class="" style="color: rgb(53, 86, 138);">else</span> {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <span class="" style="color: rgb(53, 86, 138);">switch</span> error {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <span class="" style="color: rgb(53, 86, 138);">case</span> Error.Some: <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=""> </span>default<span class="">: </span>return</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> }</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 = <span class="" style="color: rgb(53, 86, 138);">try</span> test() <span class="" style="color: rgb(53, 86, 138);">catch</span> SomeError.SomeCase {</div><div class="" style="margin: 0px; line-height: normal; min-height: 14px;"> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; line-height: normal; color: rgb(53, 86, 138);"><span class="">} </span>catch<span class=""> {</span></div><div class="" style="margin: 0px; line-height: normal; min-height: 14px;"> <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 <<a href="mailto:liamdunn@me.com" class="">liamdunn@me.com</a>> 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> <span class="" style="color: rgb(53, 86, 138);">let</span> unwrapped = optional, result = <span class="" style="color: rgb(53, 86, 138);">try</span> test() <span class="" style="color: rgb(53, 86, 138);">else</span> {</div><div class="" style="margin: 0px; line-height: normal; min-height: 14px;"> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; line-height: normal;">} <span class="" style="color: rgb(53, 86, 138);">catch</span> SomeError.SomeCase {</div><div class="" style="margin: 0px; line-height: normal; min-height: 14px;"> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; line-height: normal; color: rgb(53, 86, 138);"><span class="">} </span>catch<span class=""> {</span></div><div class="" style="margin: 0px; line-height: normal; min-height: 14px;"> <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 <span class="" style="font-family: Menlo; color: rgb(53, 86, 138);">guard</span><span class="" style="font-family: Menlo;"> </span><span class="" style="font-family: Menlo; color: rgb(53, 86, 138);">let</span><span class="" style="font-family: Menlo;"> unwrapped = optional </span>to show how <i class="">guard let</i> and the <i class="">catch</i> 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 <i class="">catch X</i> on the same line as the <i class="">try</i> 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 = <span class="" style="color: rgb(53, 86, 138);">try</span> test() <span class="" style="color: rgb(53, 86, 138);">catch</span> SomeError.SomeCase {</div><div class="" style="margin: 0px; line-height: normal; min-height: 14px;"> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; line-height: normal; color: rgb(53, 86, 138);"><span class="">} </span>catch<span class=""> {</span></div><div class="" style="margin: 0px; line-height: normal; min-height: 14px;"> <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> coordinator = <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> {</div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"> <span class="" style="color: rgb(53, 86, 138);">let</span> documentsDirectoryURL = <span class="" style="color: rgb(53, 86, 138);">try</span> <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: <span class="" style="color: rgb(53, 86, 138);">nil</span>, create: <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;"> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"> <span class="" style="color: rgb(53, 86, 138);">let</span> persistentStoreFileName = <span class="" style="color: rgb(232, 35, 0);">"CoreDataStore.sqlite"</span></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"> <span class="" style="color: rgb(53, 86, 138);">let</span> 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;"> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"> <span class="" style="color: rgb(53, 86, 138);">try</span> <span class="" style="color: rgb(88, 126, 168);">coordinator</span>.addPersistentStoreWithType(<span class="" style="color: rgb(88, 126, 168);">NSSQLiteStoreType</span>, configuration: <span class="" style="color: rgb(53, 86, 138);">nil</span>, URL: persistentStoreURL, options: <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;"> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;">} <span class="" style="color: rgb(53, 86, 138);">catch</span> MyError.Case1 {</div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;"> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;">} <span class="" style="color: rgb(53, 86, 138);">catch</span> MyError.Case2 {</div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;"> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;">} <span class="" style="color: rgb(53, 86, 138);">catch</span> MyError.Case3 {</div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;"> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;">} <span class="" style="color: rgb(53, 86, 138);">catch</span> AnotherError.Case1 {</div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;"> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;">} <span class="" style="color: rgb(53, 86, 138);">catch</span> AnotherError.Case2 {</div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;"> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;">} <span class="" style="color: rgb(53, 86, 138);">catch</span> AnotherError.Case3 {</div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;"> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo; color: rgb(53, 86, 138);"><span class="">} </span>catch<span class=""> {</span></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;"> <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 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"> </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=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div></blockquote></body></html>