<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="">I’m a ±1; for the way things are I’m a +1, but I think I’d still prefer to have typed errors that the compiler can use to check for an exhaustive list, as it would be easy for a forced conversion to result in unexpected runtime errors later if you ever need to add a new error type to your .applyAction() method, since doing so wouldn’t result in any warnings/errors at compile time.</div><div class=""><br class=""></div><div class="">I agree about catch _ and default; either default should be allowed for do/catch, or be removed from switches, to promote consistency, but that’s a separate issue I think.</div><br class=""><div><blockquote type="cite" class=""><div class="">On 20 Mar 2016, at 20:26, Tyler Fleming Cloutier 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=""><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=""> <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="" class=""> </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> {</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></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>