<div><div>Yes, I have used Result in the past. </div></div><div><br></div><div>In this case I wanted to use throws because that is what functions like map do. </div><div><br></div><div>Looks like I will have to stick with throwing, not too bad since the overhead is reasonably low. </div><div><br><div class="gmail_quote"><div>On Wed, 11 Jan 2017 at 8:03 am, T.J. Usiyan &lt;<a href="mailto:griotspeak@gmail.com">griotspeak@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_msg">I suggest using an enum to represent success and failure. It&#39;s usually referred to as `Result`. It might seem weird for the closure that you presented as an example, since it would be Result&lt;Void&gt;, but it properly captures the possibility of having thrown.<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">``` swift</div>enum UselessError : Swift.Error {<br class="gmail_msg">    case somethingBadHappened<br class="gmail_msg">}<br class="gmail_msg"><br class="gmail_msg"><br class="gmail_msg">enum Result&lt;T&gt; {<br class="gmail_msg">    case success(T)<br class="gmail_msg">    case failure(Swift.Error)<br class="gmail_msg"><br class="gmail_msg">    init(throwingClosure: (Void) throws -&gt; T) {<br class="gmail_msg">        do {<br class="gmail_msg">            self = try .success(throwingClosure())<br class="gmail_msg">        } catch {<br class="gmail_msg">            self = .failure(error)<br class="gmail_msg">        }<br class="gmail_msg">    }<br class="gmail_msg">}<div class="gmail_msg"><br class="gmail_msg">func burnItDown() throws -&gt; Void {<br class="gmail_msg">    throw UselessError.somethingBadHappened<br class="gmail_msg">}<br class="gmail_msg"><br class="gmail_msg">Result(throwingClosure: burnItDown)<div class="gmail_msg">```</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"></div></div></div><div class="gmail_extra gmail_msg"><br class="gmail_msg"><div class="gmail_quote gmail_msg"></div></div><div class="gmail_extra gmail_msg"><div class="gmail_quote gmail_msg">On Mon, Jan 9, 2017 at 10:28 PM, Jacob Bandes-Storch via swift-users <span class="gmail_msg">&lt;<a href="mailto:swift-users@swift.org" class="gmail_msg" target="_blank">swift-users@swift.org</a>&gt;</span> wrote:<br class="gmail_msg"></div></div><div class="gmail_extra gmail_msg"><div class="gmail_quote gmail_msg"><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_msg">Moving to swift-users list.<div class="gmail_extra gmail_msg"><br clear="all" class="gmail_msg"><div class="gmail_msg"><div class="m_-4601072638714702815m_7830697524789680540m_9079363423569745951gmail_signature gmail_msg" data-smartmail="gmail_signature"><div class="gmail_msg"><div class="gmail_msg">No, there&#39;s no way to do this today. The point of rethrows is that within one call site, &quot;f(block)&quot; can be treated as throwing if the block throws, or not throwing if the block doesn&#39;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 class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">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 class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">struct FStore&lt;T: () throws -&gt; Void&gt; {  // made-up syntax</div><div class="gmail_msg">    let f: T</div><div class="gmail_msg">    func call() rethrows(T) { try f() }  // throws-ness of this function depends on throws-ness of T</div><div class="gmail_msg">}</div></div></div></div><br><br><br class="gmail_msg"><div class="gmail_quote gmail_msg"><div class="gmail_msg"><div class="m_-4601072638714702815h5 gmail_msg">On Mon, Jan 9, 2017 at 9:21 PM, Howard Lovatt via swift-evolution <span class="gmail_msg">&lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br class="gmail_msg"></div></div><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_msg"><div class="m_-4601072638714702815h5 gmail_msg"><div class="gmail_msg">Hi,<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">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 class="gmail_msg"><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><p class="m_-4601072638714702815m_7830697524789680540m_9079363423569745951m_-6115875790740195702gmail-p1 gmail_msg"><span class="m_-4601072638714702815m_7830697524789680540m_9079363423569745951m_-6115875790740195702gmail-s1 gmail_msg">    </span>struct FStore {<br class="gmail_msg">        let f: () throws -&gt; Void<br class="gmail_msg">        init(f: @escaping () throws -&gt; Void) { self.f = f }<br class="gmail_msg">        func call() throws { try f() } // Can&#39;t put rethrows here - have to use throws<br class="gmail_msg">    }</p></div><div class="gmail_msg">Is there a better solution?</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Thanks for any suggestions,</div><div class="gmail_msg"><br clear="all" class="gmail_msg"><div class="gmail_msg"><div class="m_-4601072638714702815m_7830697524789680540m_9079363423569745951m_-6115875790740195702gmail_signature gmail_msg">  -- Howard.<br class="gmail_msg"></div></div><br><br></div></div><br><br><br class="gmail_msg"></div></div>_______________________________________________<br class="gmail_msg"><br><br>swift-evolution mailing list<br class="gmail_msg"><br><br><a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg"><br><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg"><br><br><br class="gmail_msg"></blockquote></div><br class="gmail_msg"></div></div><br><br><br class="gmail_msg"></blockquote></div></div><div class="gmail_extra gmail_msg"><div class="gmail_quote gmail_msg"><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">_______________________________________________<br class="gmail_msg"><br><br>swift-users mailing list<br class="gmail_msg"><br><br><a href="mailto:swift-users@swift.org" class="gmail_msg" target="_blank">swift-users@swift.org</a><br class="gmail_msg"><br><br><a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a><br class="gmail_msg"><br><br><br class="gmail_msg"></blockquote></div><br class="gmail_msg"></div><br><br></blockquote></div></div><div dir="ltr">-- <br></div><div data-smartmail="gmail_signature">-- Howard.</div>