<div dir="ltr">Moving to swift-users list.<div class="gmail_extra"><br clear="all"><div><div class="m_9079363423569745951gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>No, there's no way to do this today. The point of rethrows is that within one call site, "f(block)" can be treated as throwing if the block throws, or not throwing if the block doesn't throw. In your example, once the FStore object is constructed, the information about the original passed-in function is lost, so the caller has no way to know whether call() can throw or not.</div><div><br></div><div>If this *were* possible, the information would somehow need to be encoded in the type system when creating FStore(f: block). That would require something like dependent typing, or generic-param-based-rethrows, e.g.</div><div><br></div><div>struct FStore<T: () throws -> Void> { // made-up syntax</div><div> let f: T</div><div> func call() rethrows(T) { try f() } // throws-ness of this function depends on throws-ness of T</div><div>}</div></div></div></div>
<br><div class="gmail_quote">On Mon, Jan 9, 2017 at 9:21 PM, Howard Lovatt via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>If I have an escaping function that I store and then call, I need to declare the calling function as throwing, not rethrowing. EG:</div><div>
<p class="m_9079363423569745951m_-6115875790740195702gmail-p1"><span class="m_9079363423569745951m_-6115875790740195702gmail-s1"> </span>struct FStore {<br> let f: () throws -> Void<br> init(f: @escaping () throws -> Void) { self.f = f }<br> func call() throws { try f() } // Can't put rethrows here - have to use throws<br> }</p></div><div>Is there a better solution?</div><div><br></div><div>Thanks for any suggestions,</div><div><br clear="all"><div><div class="m_9079363423569745951m_-6115875790740195702gmail_signature"> -- Howard.<br></div></div>
</div></div>
<br>______________________________<wbr>_________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailma<wbr>n/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div></div>