<div dir="ltr"><div class="markdown-here-wrapper" style=""><p style="margin:0px 0px 1.2em!important">2017-02-19 23:29 GMT+03:00 Matthew Johnson &lt;<a href="mailto:matthew@anandabits.com" target="_blank">matthew@anandabits.com</a>&gt;:</p>
<p style="margin:0px 0px 1.2em!important"></p><div class="markdown-here-exclude"><p></p><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>Thanks.  There is nothing wrong with this at all.  Your second `exec` would not accept a non-throwing function because `Never` cannot conform to `Default`.  If it didn’t include the `Default` constraint it would not be able to `throw E()`.</div></div></blockquote><p></p></div><p style="margin:0px 0px 1.2em!important"></p>
<p style="margin:0px 0px 1.2em!important">But that raises another concern. In a previous discussion, it was taken for granted that <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">Never</code> should conform to all protocols, because if one obtains an instance of <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">Never</code> (and they won’t), then everything is possible. But now we say that <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">Never</code> can’t conform to <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">Default</code>, because this would break its very invariant. Also it can’t conform to any protocol with static members or initializers.</p>
<p style="margin:0px 0px 1.2em!important">But then basically, <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">Never</code> trick can’t be used when we request anything more than <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">Error</code> from generic error type (with static members or initializers). So this approach turns out to be more limiting than <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">rethrows</code>.<br>Don’t misunderstand me—I love the idea of <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">Never</code> replacing <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">rethrows</code>. Just want to make sure we don’t lose anything important by the way.</p>
<p style="margin:0px 0px 1.2em!important"></p><div class="markdown-here-exclude"><p></p><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>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><br></div><div>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`.  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.  We have more flexibility in API design under Joe’s proposal.</div></div></blockquote><p></p></div><p style="margin:0px 0px 1.2em!important"></p>
<p style="margin:0px 0px 1.2em!important">Nice. Whether we can throw the error ourselves depends on our ability to create the error.</p>
<p style="margin:0px 0px 1.2em!important"></p><div class="markdown-here-exclude"><p></p><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>You did make a great point about coalescing error types from several different function arguments.  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></blockquote><p></p></div><p style="margin:0px 0px 1.2em!important"></p>
<div title="MDH:PGRpdiBjbGFzcz0iZ21haWxfZXh0cmEiPjxkaXYgY2xhc3M9ImdtYWlsX3F1b3RlIj4yMDE3LTAy
LTE5IDIzOjI5IEdNVCswMzowMCBNYXR0aGV3IEpvaG5zb24gPHNwYW4gZGlyPSJsdHIiPiZsdDs8
YSBocmVmPSJtYWlsdG86bWF0dGhld0BhbmFuZGFiaXRzLmNvbSIgdGFyZ2V0PSJfYmxhbmsiPm1h
dHRoZXdAYW5hbmRhYml0cy5jb208L2E+Jmd0Ozwvc3Bhbj46PGJsb2NrcXVvdGUgY2xhc3M9Imdt
YWlsX3F1b3RlIiBzdHlsZT0ibWFyZ2luOjAgMCAwIC44ZXg7Ym9yZGVyLWxlZnQ6MXB4ICNjY2Mg
c29saWQ7cGFkZGluZy1sZWZ0OjFleCI+PGRpdiBzdHlsZT0id29yZC13cmFwOmJyZWFrLXdvcmQi
PjxkaXY+VGhhbmtzLiAmbmJzcDtUaGVyZSBpcyBub3RoaW5nIHdyb25nIHdpdGggdGhpcyBhdCBh
bGwuICZuYnNwO1lvdXIgc2Vjb25kIGBleGVjYCB3b3VsZCBub3QgYWNjZXB0IGEgbm9uLXRocm93
aW5nIGZ1bmN0aW9uIGJlY2F1c2UgYE5ldmVyYCBjYW5ub3QgY29uZm9ybSB0byBgRGVmYXVsdGAu
ICZuYnNwO0lmIGl0IGRpZG7igJl0IGluY2x1ZGUgdGhlIGBEZWZhdWx0YCB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