<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 class=""><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="" style="margin: 0px; line-height: normal;"><div class="" style="margin: 0px; line-height: normal;">Also as a brief aside, it’s not super intuitive to me that the syntax for the catch pattern matching wildcard is&nbsp;</div><div class="" style="margin: 0px; line-height: normal;"><br class=""></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);">catch</span><span class="" style="font-family: Menlo; font-size: 11px;">&nbsp;<font color="#bb2ca2" class="">_</font></span></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-family: Menlo; font-size: 11px;"><font color="#bb2ca2" class=""><br class=""></font></span></div><div class="" style="margin: 0px; line-height: normal;">whereas it is</div><div class="" style="margin: 0px; line-height: normal;"><br class=""></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);">default</span></div><div class="" style="margin: 0px; line-height: normal;">&nbsp;</div><div class="" style="margin: 0px; line-height: normal;">for switches.</div></div></div></blockquote><br class=""></div><div class="">I do believe you can just say `catch`:</div><div class=""><br class=""></div><div class=""><div class="">&nbsp; 4&gt; do {</div><div class="">&nbsp; 5. &nbsp; &nbsp; try throwing()</div><div class="">&nbsp; 6. } catch let e as E { ...</div><div class="">&nbsp; 7. } catch {</div><div class="">&nbsp; 8. &nbsp; &nbsp; print(error)</div><div class="">&nbsp; 9. }</div></div><br class=""><div class="">
<div class="">— Radek</div>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On 20 Mar 2016, at 21:26, Tyler Fleming Cloutier 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=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I recall that there was quite a bit of discussion a while back about adding typed error declarations for methods that throw for the purpose of exhaustive pattern matching on errors.<div class=""><br class=""></div><div class="">There were interesting arguments on either side, and I think that the result was to maintain the status quo. There’s still the issue of having to add the extra catch statement to every do block for exhaustive matches.</div><div class=""><br class=""></div><div class="">Would it be wise to allow force conversion for the cases in which the developer believes the match is exhaustive? ie</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">do</span> {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> action = <span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">chooseAction</span>(game)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; game = <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">try</span> game.<span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">applyAction</span>(action)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">} <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">catch</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> e <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">as</span> <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">ActionError</span> {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; &nbsp; game.<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">failedAction</span> = e</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">} <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">catch</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">_</span> {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);" class=""><span style="" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">fatalError</span><span style="" class="">(</span>“This is an unfortunate bit of noise :/"<span style="" class="">)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-family: Helvetica; font-size: 12px;" class="">becomes</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-family: Helvetica; font-size: 12px;" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal;" class=""><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="color: rgb(187, 44, 162);" class="">do</span>&nbsp;{</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class="">&nbsp; &nbsp;&nbsp;<span style="color: rgb(187, 44, 162);" class="">let</span>&nbsp;action =&nbsp;<span style="color: rgb(49, 89, 93);" class="">chooseAction</span>(game)</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class="">&nbsp; &nbsp;&nbsp;game =&nbsp;<span style="color: rgb(187, 44, 162);" class="">try</span>&nbsp;game.<span style="color: rgb(49, 89, 93);" class="">applyAction</span>(action)</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class="">}&nbsp;<span style="color: rgb(187, 44, 162);" class="">catch</span>&nbsp;<span style="color: rgb(187, 44, 162);" class="">let</span>&nbsp;e&nbsp;<span style="color: rgb(187, 44, 162);" class="">as!</span>&nbsp;<span style="color: rgb(79, 129, 135);" class="">ActionError</span>&nbsp;{</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class="">&nbsp; &nbsp;&nbsp;game.<span style="color: rgb(79, 129, 135);" class="">failedAction</span>&nbsp;= e</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class="">}</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><br class=""></div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class="">Also as a brief aside, it’s not super intuitive to me that the syntax for the catch pattern matching wildcard is&nbsp;</div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">catch</span><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp;<font color="#bb2ca2" class="">_</font></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-family: Menlo; font-size: 11px;" class=""><font color="#bb2ca2" class=""><br class=""></font></span></div><div style="margin: 0px; line-height: normal;" class="">whereas it is</div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">default</span></div><div style="margin: 0px; line-height: normal;" class="">&nbsp;</div><div style="margin: 0px; line-height: normal;" class="">for switches. I think I saw Chris mention somewhere that default was chosen because of it’s wide familiarity. Does anyone recall the reason?</div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class="">Thanks,</div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class="">Tyler</div></div></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>