<div dir="ltr"><div class="markdown-here-wrapper" style=""><p style="margin:0px 0px 1.2em!important">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">rethrows</code>.<br>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">rethrows</code> has semantic information that function itself does not throw—it would be lost.</p>
<p style="margin:0px 0px 1.2em!important">Secondly, <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> allows a function with multiple throwing function parameters to become non-throwing iff all the arguments are non-throwing.<br>How would you express it with generics?<br>In the proposal, in this case you are required to provide a non-generic supertype of all used error types. This type can’t just turn into <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> automatically.</p>
<p style="margin:0px 0px 1.2em!important">One solution would be to retain <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> as an additional attribute.<br>It would help with semantic information, and resulting error will be able to turn into <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> as a special case—now that we know, that this function doesn’t throw that error itself.</p>
<p style="margin:0px 0px 1.2em!important">2017-02-19 0:16 GMT+03:00 Martin Waitz &lt;<a href="mailto:tali@admingilde.org" target="_blank">tali@admingilde.org</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"><br><div><span><blockquote type="cite"><div>Am 18.02.2017 um 17:37 schrieb Matthew Johnson via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;:</div><br class="m_-5212946143225501370m_-3606562864695778611Apple-interchange-newline"><div><div style="word-wrap:break-word">Thank you for taking the time to put this proposal together Anton!  I really want to see typed throws make it into Swift 4.  This will be a very nice feature to have.<div><br></div><div>I noticed that you included Joe Groff’s idea of replacing `rethrows` by making every function have an error type which is by default `Never` for non-throwing functions and `Error` for throwing functions that do not specify an error type.  </div><div><br></div><div>I want to urge you to consider updating the proposal to take this direction now rather than later.  This is a breaking change which means the longer we wait the harder it is to justify.  In fact, I think incorporating the breaking change could increase the chances of it being accepted for Swift 4.  Without that it is a purely additive change and those are not being given priority in the Swift 4 release.</div></div></div></blockquote><div><br></div></span><div>Seconded.</div><div>With typed throwing function parameters, it makes a lot of sense to be able to specify the rethrown type, based on the function given as parameter.<br></div></div></div></blockquote><p></p></div><p style="margin:0px 0px 1.2em!important"></p>
<div title="MDH:PGRpdiBjbGFzcz0iZ21haWxfZXh0cmEiPjxkaXYgY2xhc3M9ImdtYWlsX3F1b3RlIj5Ob3cgdGhh
dCBJIHRoaW5rIGFib3V0IGl0LCBnZW5lcmljIHRocm93cyBkb2VzIG5vdCBleGFjdGx5IGNvdmVy
IGByZXRocm93c2AuPC9kaXY+PGRpdiBjbGFzcz0iZ21haWxfcXVvdGUiPkZpcnN0bHksIGByZXRo
cm93c2AgaGFzIHNlbWFudGljIGluZm9ybWF0aW9uIHRoYXQgZnVuY3Rpb24gaXR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