<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 19, 2017, at 2:16 PM, Anton Zhilin &lt;<a href="mailto:antonyzhilin@gmail.com" class="">antonyzhilin@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="markdown-here-wrapper" style=""><p style="margin:0px 0px 1.2em!important" class="">2017-02-19 22:59 GMT+03:00 Matthew Johnson &lt;<a href="mailto:matthew@anandabits.com" target="_blank" class="">matthew@anandabits.com</a>&gt;:</p><div style="margin: 0px 0px 1.2em !important;" class=""><br class="webkit-block-placeholder"></div><div class="markdown-here-exclude"><div class=""><br class="webkit-block-placeholder"></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><span class=""><blockquote type="cite" class=""><div class="">On Feb 19, 2017, at 1:32 PM, Anton Zhilin &lt;<a href="mailto:antonyzhilin@gmail.com" target="_blank" class="">antonyzhilin@gmail.com</a>&gt; wrote:</div><br class="m_-2614446803700265113Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="m_-2614446803700265113markdown-here-wrapper"><p style="margin:0px 0px 1.2em!important" class="">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="">rethrows</code>.<br class="">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="">rethrows</code> has semantic information that function itself does not throw—it would be lost.</p></div></div></div></blockquote></span>Can you elaborate further on what you mean by this?</div></div></blockquote><div class=""><br class="webkit-block-placeholder"></div></div><div style="margin: 0px 0px 1.2em !important;" class=""><br class="webkit-block-placeholder"></div>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px" class=""><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" class="">protocol Default { init() }

func exec(f: () throws -&gt; Void) rethrows
{
    try f()
    throw MyError()  // error because of rethrows
}

func exec&lt;E&gt;(f: () throws(E) -&gt; Void) throws(E)
     where E: Error &amp; Default
{
    try f()
    throw E()  // okay
}
</code></pre><div title="MDH:PGRpdiBjbGFzcz0iZ21haWxfZXh0cmEiPjxkaXYgY2xhc3M9ImdtYWlsX3F1b3RlIj4yMDE3LTAy
LTE5IDIyOjU5IEdNVCswMzowMCBNYXR0aGV3IEpvaG5zb24gPHNwYW4gZGlyPSJsdHIiPiZsdDs8
YSBocmVmPSJtYWlsdG86bWF0dGhld0BhbmFuZGFiaXRzLmNvbSIgdGFyZ2V0PSJfYmxhbmsiPm1h
dHRoZXdAYW5hbmRhYml0cy5jb208L2E+Jmd0Ozwvc3Bhbj46PGJsb2NrcXVvdGUgY2xhc3M9Imdt
YWlsX3F1b3RlIiBzdHlsZT0ibWFyZ2luOjAgMCAwIC44ZXg7Ym9yZGVyLWxlZnQ6MXB4ICNjY2Mg
c29saWQ7cGFkZGluZy1sZWZ0OjFleCI+PGRpdiBzdHlsZT0id29yZC13cmFwOmJyZWFrLXdvcmQi
PjxkaXY+PHNwYW4gY2xhc3M9IiI+PGJsb2NrcXVvdGUgdHlwZT0iY2l0ZSI+PGRpdj5PbiBGZWIg
MTksIDIwMTcsIGF0IDE6MzIgUE0sIEFudG9uIFp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ocm93IEUoKSAmbmJzcDsvLyBv
a2F5PC9kaXY+PGRpdj59PC9kaXY+PGRpdj5gYGA8YnI+PC9kaXY+PC9kaXY+PC9kaXY+" style="height:0;width:0;max-height:0;max-width:0;overflow:hidden;font-size:0em;padding:0;margin:0" class="">​</div></div></div>
</div></blockquote></div><br class=""><div class="">Thanks. &nbsp;There is nothing wrong with this at all. &nbsp;Your second `exec` would not accept a non-throwing function because `Never` cannot conform to `Default`. &nbsp;If it didn’t include the `Default` constraint it would not be able to `throw E()`. &nbsp;</div><div class=""><br class=""></div><div class="">If you remove the `Default` constraint and change `throws(E)` to `throws`, and throw `MyError()` in place of `E()` in both places then it behaves exactly as the first example. We don’t lose any expressivity at all.</div><div class=""><br class=""></div><div class="">This is actually an example of a strength of Joe’s suggestion: the second `exec` is able to throw an error of a type that matches the error that might be thrown by the calling argument `f`. &nbsp;I’m not sure of where this might be useful but it is definitely not possible with `rethrows` while it is possible with Joe’s proposal. &nbsp;We have more flexibility in API design under Joe’s proposal.</div><div class=""><br class=""></div><div class="">You did make a great point about coalescing error types from several different function arguments. &nbsp;That’s an edge case, but the inability to coalesce is indeed a problem that probably needs to be addressed by the typed throws proposal in one way or another (if we don’t go with Joe’s suggestion we would need to specify how `rethrows` behaves in cases like this in some detail).</div><div class=""><br class=""></div><div class=""><br class=""></div></body></html>