<div dir="ltr">On 29 October 2017 at 14:02, Johannes Weiß <span dir="ltr">&lt;<a href="mailto:johannesweiss@apple.com" target="_blank">johannesweiss@apple.com</a>&gt;</span> wrote:<div><br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="auto">Definitely not arguing with that. But there are (valid?) cases when you want a recursive closure which doesn’t have a native recursion mechanism and then `fix` can be useful I’d argue. I think more straightforward than<div><br></div><div><span class="gmail-"><blockquote type="cite"><blockquote type="cite"><div><blockquote type="cite"><blockquote type="cite"><font color="#000000"><span style="background-color:rgba(255,255,255,0)">recursive.c = { x in<br>       (x == 0) ? 1 : x * recursive.c(x - 1)<br>   }</span></font></blockquote></blockquote></div></blockquote></blockquote><div><br></div></span></div></div></blockquote><div><br></div><div><div><div class="gmail_extra"><div class="gmail_quote"><div>you can do without &quot;recursive.c&quot;:</div><div><br></div><div><div>var factorial: ((Int) -&gt; Int)!</div><div><br></div><div>factorial = { n in</div><div><span style="white-space:pre">        </span>n == 0 ? 1 : n * factorial(n - 1)</div><div>}</div><div><br></div><div>factorial(5) // 120</div></div><div><br></div><div> <br></div></div></div></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="auto"><div><span class="gmail-"><div></div></span><div>. But fortunately have local functions, I can only recall wanting a recursive closure once.</div><span class="gmail-HOEnZb"><font color="#888888"><div><br></div></font></span></div></div></blockquote><div><br></div><div>in down to earth practical programming even if i didn&#39;t have local functions i probably wouldn&#39;t bother abusing closures to implement recursion, would just used what&#39;s available: methods. and if there is some extra state to pass from the outer scopes, well, so be it, either via parameters of via some instance variables, etc. wasn&#39;t too much of a problem in good old C/C++. in a way, knowing exact state you want to pass and passing it explicitly organises the code and the reasoning about it.</div><div><br></div><div>Mike</div><div><br></div></div></div></div></div>