<div dir="ltr">Sorry for the delay in replying - I was called up for jury duty!<div><br></div><div>For recursive closures the compiler would require two changes; if the variable is a function type then:</div><div><br></div><div>  1. It can reference itself, e.g. `let fact: (Int) -&gt; Int = { $0 &lt; 2 ? 1 : $0 * fact($0 - 1) }` becomes legal. This is not difficult to do because `fact` is a pointer and therefore of known size.</div><div>  2. When a reference to a function type is made and that function isn&#39;t known, the compiler puts a placeholder in (it knows the size - it is a pointer) and then comes back and fills in the blank latter (just as it currently does for functions).</div><div><br></div><div>These are not show stoppers, it is what the compiler already does for functions.</div><div><br></div><div>Will respond to generics comments in reply to Robert Widmann email.</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature">  -- Howard.<br></div></div>
<br><div class="gmail_quote">On 15 November 2017 at 17:01, Slava Pestov <span dir="ltr">&lt;<a href="mailto:spestov@apple.com" target="_blank">spestov@apple.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><br><div><br><blockquote type="cite"><span class=""><div>On Nov 14, 2017, at 6:56 PM, Howard Lovatt via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_-4583552821635402178Apple-interchange-newline"></span><span class=""><div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">  2. Allow closures when assigned to a function type to be:</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">      2a. Recursive.</div></div></span></blockquote><div><br></div><div>Local functions can also be mutually recursive:</div><div><br></div><div>func f() {</div><div>  func foo() { bar() }</div><div>  func bar() { foo() }</div><div>}</div><div><br></div><div>This would not work with let bindings, which are not visible before the location where they are defined.</div><span class=""><br><blockquote type="cite"><div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">      2b. Annotatable with:</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">            2bi.  @inline</div></div></blockquote><div><br></div></span><div>Neither closures nor local functions benefit from being annotated with @_inlineable, because they can only be referenced from inside their defining function, and not across module boundaries. So the optimizer can already inline the function or closure if needed.</div><br><blockquote type="cite"><div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">            2bii. @escaping</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">      2c. Generic.</div></div></blockquote></div><br><div>See my other response to this thread.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Slava</div></font></span></div></blockquote></div><br></div>