<div dir="ltr"><span class="im" style="font-size:13px"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word"><div style="margin:0px;line-height:normal"><div 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 </div><div style="margin:0px;line-height:normal"><br></div><div style="margin:0px;line-height:normal"><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">catch</span><span style="font-family:Menlo;font-size:11px"> <font color="#bb2ca2">_</font></span></div><div style="margin:0px;line-height:normal"><span style="font-family:Menlo;font-size:11px"><font color="#bb2ca2"><br></font></span></div><div style="margin:0px;line-height:normal">whereas it is</div><div style="margin:0px;line-height:normal"><br></div><div style="margin:0px;line-height:normal"><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">default</span></div><div style="margin:0px;line-height:normal"> </div><div style="margin:0px;line-height:normal">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"><br></div></div></div></blockquote></div><div class="gmail_extra"><br></div></span><span style="font-size:13px">I think it was about a proposal for using </span><span style="font-family:Menlo;font-size:11px"><font color="#000000">case _: </font></span><span style="font-size:13px">instead of </span><span style="color:rgb(0,0,0);font-family:Menlo;font-size:11px">default:</span><br></div><div class="gmail_extra"><br><div class="gmail_quote">2016-03-20 20:26 GMT+00:00 Tyler Fleming Cloutier via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">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><br></div><div>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><br></div><div>Would it be wise to allow force conversion for the cases in which the developer believes the match is exhaustive? ie</div><div><br></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:#bb2ca2">do</span> {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">    <span style="color:#bb2ca2">let</span> action = <span style="color:#31595d">chooseAction</span>(game)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">    game = <span style="color:#bb2ca2">try</span> game.<span style="color:#31595d">applyAction</span>(action)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">} <span style="color:#bb2ca2">catch</span> <span style="color:#bb2ca2">let</span> e <span style="color:#bb2ca2">as</span> <span style="color:#4f8187">ActionError</span> {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">    game.<span style="color:#4f8187">failedAction</span> = e</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">} <span style="color:#bb2ca2">catch</span> <span style="color:#bb2ca2">_</span> {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(209,47,27)"><span style="color:#000000">    </span><span style="color:#3d1d81">fatalError</span><span style="color:#000000">(</span>“This is an unfortunate bit of noise :/&quot;<span style="color:#000000">)</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">}</div></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-family:Helvetica;font-size:12px">becomes</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-family:Helvetica;font-size:12px"><br></span></div><div style="margin:0px;line-height:normal"><div style="font-family:Menlo;font-size:11px;margin:0px;line-height:normal"><span style="color:rgb(187,44,162)">do</span> {</div><div style="font-family:Menlo;font-size:11px;margin:0px;line-height:normal">    <span style="color:rgb(187,44,162)">let</span> action = <span style="color:rgb(49,89,93)">chooseAction</span>(game)</div><div style="font-family:Menlo;font-size:11px;margin:0px;line-height:normal">    game = <span style="color:rgb(187,44,162)">try</span> game.<span style="color:rgb(49,89,93)">applyAction</span>(action)</div><div style="font-family:Menlo;font-size:11px;margin:0px;line-height:normal">} <span style="color:rgb(187,44,162)">catch</span> <span style="color:rgb(187,44,162)">let</span> e <span style="color:rgb(187,44,162)">as!</span> <span style="color:rgb(79,129,135)">ActionError</span> {</div><div style="font-family:Menlo;font-size:11px;margin:0px;line-height:normal">    game.<span style="color:rgb(79,129,135)">failedAction</span> = e</div><div style="font-family:Menlo;font-size:11px;margin:0px;line-height:normal">}</div><div style="font-family:Menlo;font-size:11px;margin:0px;line-height:normal"><br></div><div style="font-family:Menlo;font-size:11px;margin:0px;line-height:normal"><br></div><div 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 </div><div style="margin:0px;line-height:normal"><br></div><div style="margin:0px;line-height:normal"><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">catch</span><span style="font-family:Menlo;font-size:11px"> <font color="#bb2ca2">_</font></span></div><div style="margin:0px;line-height:normal"><span style="font-family:Menlo;font-size:11px"><font color="#bb2ca2"><br></font></span></div><div style="margin:0px;line-height:normal">whereas it is</div><div style="margin:0px;line-height:normal"><br></div><div style="margin:0px;line-height:normal"><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">default</span></div><div style="margin:0px;line-height:normal"> </div><div style="margin:0px;line-height:normal">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"><br></div><div style="margin:0px;line-height:normal">Thanks,</div><div style="margin:0px;line-height:normal"><br></div><div style="margin:0px;line-height:normal">Tyler</div></div></div><br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr">Pedro Vieira<div><a href="http://pedrovieira.me" target="_blank">http://pedrovieira.me</a></div></div></div></div></div>
</div>