<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="">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=""> <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=""> 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=""> 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="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">fatalError</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span>“This is an unfortunate bit of noise :/"<span style="font-variant-ligatures: no-common-ligatures; color: #000000" 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> {</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""> <span style="color: rgb(187, 44, 162);" class="">let</span> action = <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=""> game = <span style="color: rgb(187, 44, 162);" class="">try</span> 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="">} <span style="color: rgb(187, 44, 162);" class="">catch</span> <span style="color: rgb(187, 44, 162);" class="">let</span> e <span style="color: rgb(187, 44, 162);" class="">as!</span> <span style="color: rgb(79, 129, 135);" class="">ActionError</span> {</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""> game.<span style="color: rgb(79, 129, 135);" class="">failedAction</span> = 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 </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=""> <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=""> </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></body></html>