<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="">I don’t know what the compiler does internally. However, I look at a signature like<div class=""><br class=""></div><div class="">func forEach(fn:Element throws-&gt;()) rethrows</div><div class=""><br class=""></div><div class="">and imagine that conceptually this exposes two overloads for this “forEach” function:</div><div class=""><br class=""></div><div class="">a)<span class="Apple-tab-span" style="white-space:pre">        </span>func forEach(fn:Element-&gt;())</div><div class=""><br class=""></div><div class="">b)<span class="Apple-tab-span" style="white-space:pre">        </span>func forEach(fn:Element throws-&gt;()) throws</div><div class=""><br class=""></div><div class="">In fact, I expected the swift CLI to give me an error when I attempted to define all three of these as functions, but no such luck.</div><div class=""><br class=""></div><div class="">-DW</div><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 21, 2015, at 7:09 PM, Jordan Rose via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">John, IIRC you had some reason why this wasn't a great idea, but I can't remember it. It seems useful to me too, if not something that comes up <i class="">too</i>&nbsp;often.</div><div class=""><br class=""></div><div class="">Jordan</div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 20, 2015, at 2:46 , Alexandre Lopoukhine via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Hi Dmitri,<br class=""><br class="">This is a better example than any that I have come up with so far as to why “rethrows” should be a part of the signature. You shouldn’t have to use “try!” to apply a non-throwing function, like {print($0)} to “forEach”.<br class=""><br class="">— Sasha<br class=""><br class=""><br class=""><blockquote type="cite" class="">On 20 Dec 2015, at 13:37, Dmitri Gribenko &lt;<a href="mailto:gribozavr@gmail.com" class="">gribozavr@gmail.com</a>&gt; wrote:<br class=""><br class="">Hi Alexandre,<br class=""><br class="">I think for this use case we don't actually need 'rethrows' to become<br class="">a part of the closure type, we just need the compiler to allow and<br class="">"instantiate" it in more places.<br class=""><br class="">The case where we would need 'rethrows' to become a first class part<br class="">of the type system is if we wanted 'rethrows' to be a part of the<br class="">signature of the closure itself, for example:<br class=""><br class="">(swift) let forEach = [ 10, 20, 30 ].forEach<br class="">// forEach : (@noescape (Int) throws -&gt; Void) throws -&gt; () = (Function)<br class=""><br class="">Here, a more precise type would be (@noescape (Int) throws -&gt; Void)<br class="">rethrows -&gt; Void.<br class=""><br class="">Dmitri<br class=""><br class="">-- <br class="">main(i,j){for(i=2;;i++){for(j=2;j&lt;i;j++){if(!(i%j)){j=0;break;}}if<br class="">(j){printf("%d\n",i);}}} /*Dmitri Gribenko &lt;<a href="mailto:gribozavr@gmail.com" class="">gribozavr@gmail.com</a>&gt;*/<br class=""></blockquote><br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></div></blockquote></div><br class="">
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=nE9rxSXA5G4kxsTVkgv43vFcOQoCM-2FU-2BigXPSqPoICLq4-2BGzFT8qg7u79B3U6jhjsYbUH5obtbYdUgeO-2BPZAlh7xqTKdhzXuoQ-2FwJEpI5oOxogrTAF9-2Fs1A7WEIvOXP7ydd2qupGn0DeYcx1si4L7jC5K2yqv71RpDtjd9E2JgauL4hyDK9OQxVH9agT4dFxBPAjKpdkJfAnpQBIWgeaKUaqh7Z4oIAL7BKcLE9EWn0-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
</div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></body></html>