<div dir="ltr"><div class="markdown-here-wrapper" style=""><p style="margin:0px 0px 1.2em!important">How about this:</p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important">func bypassRethrows<E: Error>(_ f: () throws(E) -> ()) throws(E) {
if let e = (MyError() as Error) as? E {
throw e
}
}
</code></pre><p style="margin:0px 0px 1.2em!important">I obviously can’t “test” this right now, but should work?</p>
<p style="margin:0px 0px 1.2em!important">2017-02-22 3:42 GMT+03:00 Colin Barrett <<a href="mailto:colin@springsandstruts.com" target="_blank">colin@springsandstruts.com</a>>:</p>
<p style="margin:0px 0px 1.2em!important"></p><div class="markdown-here-exclude"><p></p><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div class="gmail_quote"><span class="gmail-"><div>On Sun, Feb 19, 2017 at 2:34 PM Anton Zhilin via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-m_-2809003803879918586gmail_msg"><div class="gmail-m_-2809003803879918586m_-5940626585113039258markdown-here-wrapper gmail-m_-2809003803879918586gmail_msg"><p style="margin:0px 0px 1.2em" class="gmail-m_-2809003803879918586gmail_msg">Now that I think about it, generic throws does not exactly cover <code style="font-size:0.85em;font-family:consolas,inconsolata,courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline" class="gmail-m_-2809003803879918586gmail_msg">rethrows</code>.<br class="gmail-m_-2809003803879918586gmail_msg">Firstly, <code style="font-size:0.85em;font-family:consolas,inconsolata,courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline" class="gmail-m_-2809003803879918586gmail_msg">rethrows</code> has semantic information that function itself does not throw—it would be lost.</p></div></div></blockquote></span><div>That's not true. Parametric polymorphism guarantees that rethrows and polymorphic throw are the same. </div><div><br></div><div>For example, you can prove that as a consequence of parametricity that there is only one (pure) function in the of the set of all functions with the type ``forall A. A -> A'' and furthermore that it is the identity function.</div><div><br></div><div>The intuition behind this is that you (meaning the fiction; imagine being a function!) cannot construct your own value of "A" since you don't have any information about what "A" is. The only place to get an "A" is from your argument.</div></div></div></blockquote><p></p></div><p style="margin:0px 0px 1.2em!important"></p>
<div title="MDH:PGRpdj5Ib3cgYWJvdXQgdGhpczo8L2Rpdj48ZGl2Pjxicj48L2Rpdj48ZGl2PmBgYDwvZGl2Pjxk
aXY+ZnVuYyBieXBhc3NSZXRocm93cyZsdDtFOiBFcnJvciZndDsoXyBmOiAoKSB0aHJvd3MoRSkg
LSZndDsgKCkpIHRocm93cyhFKSB7PC9kaXY+PGRpdj48ZGl2PiZuYnNwOyAmbmJzcDsgaWYgbGV0
IGUgPSAoTXlFcnJvcigpIGFzIEVycm9yKSBhcz8gRSB7PC9kaXY+PGRpdj4mbmJzcDsgJm5ic3A7
ICZuYnNwOyAmbmJzcDsgdGhyb3cgZTwvZGl2PjxkaXY+Jm5ic3A7ICZuYnNwOyB9PC9kaXY+PGRp
dj59PC9kaXY+PGRpdj5gYGA8L2Rpdj48ZGl2Pjxicj48L2Rpdj48ZGl2Pkkgb2J2aW91c2x5IGNh
bid0ICJ0ZXN0IiB0aGlzIHJpZ2h0IG5vdywgYnV0IHNob3VsZCB3b3JrPzwvZGl2PjxkaXY+PGRp
dj48YnI+PGRpdiBjbG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