<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Oct 27, 2017, at 10:51 AM, Mike Kluev &lt;<a href="mailto:mike.kluev@gmail.com" class="">mike.kluev@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">On&nbsp;<span style="font-size:12.800000190734863px" class="">Thu, 26 Oct 2017 21:54:37 -0700&nbsp;</span><span style="font-size:12.800000190734863px" class="">Slava Pestov &lt;</span><a href="mailto:spestov@apple.com" style="font-size:12.800000190734863px" class="">spestov@apple.com</a><span style="font-size:12.800000190734863px" class="">&gt; wrote:</span><div class=""><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 style="word-wrap:break-word;line-break:after-white-space" class=""><div class=""><br style="font-size:12.800000190734863px" class=""><span class="gmail-il" style="font-size:12.800000190734863px">Closures</span><span style="font-size:12.800000190734863px" class="">&nbsp;</span><span class="gmail-il" style="font-size:12.800000190734863px">cannot</span><span style="font-size:12.800000190734863px" class="">&nbsp;</span><span class="gmail-il" style="font-size:12.800000190734863px">replace</span><span style="font-size:12.800000190734863px" class="">&nbsp;</span><span class="gmail-il" style="font-size:12.800000190734863px">all</span><span style="font-size:12.800000190734863px" class="">&nbsp;</span><span class="gmail-il" style="font-size:12.800000190734863px">uses</span><span style="font-size:12.800000190734863px" class="">&nbsp;</span><span class="gmail-il" style="font-size:12.800000190734863px">of</span><span style="font-size:12.800000190734863px" class="">&nbsp;</span><span class="gmail-il" style="font-size:12.800000190734863px">local</span><span style="font-size:12.800000190734863px" class="">&nbsp;</span><span class="gmail-il" style="font-size:12.800000190734863px">functions</span><span style="font-size:12.800000190734863px" class="">.&nbsp;</span><span class="gmail-il" style="font-size:12.800000190734863px">Local</span><span style="font-size:12.800000190734863px" class="">&nbsp;</span><span class="gmail-il" style="font-size:12.800000190734863px">functions</span><span style="font-size:12.800000190734863px" class="">&nbsp;can be recursive, and have a generic parameter list.</span><br style="font-size:12.800000190734863px" class=""></div><div class=""><span style="font-size:12.800000190734863px" class=""><br class=""></span></div></div></blockquote><div class=""><br class=""></div><div class=""><div class="">FTM, local functions do not help with "keep functions short" and "keep indentation level small" rules of thumb.<br class=""></div></div></div></div></div></div></div></blockquote><div><br class=""></div>So do structs and classes ;-)</div><div><br class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">what are the actual benefits of local vs non local functions? locality principle? (define something where it is used). but we do not have it in much more important cases, say, with static variables - we have to declare them outside of functions. ditto for normal variables in extensions - no matter how carefully i group functions in individual extensions based on their purpose -- potentially in different files -- it all breaks once i need to add a single variable to that group which i have to to in the class itself.</div></div></div></div></div></blockquote><div><br class=""></div>Local functions can capture bindings from the outer function, just like methods can capture ‘self’ from the outer type. I don’t think a function with local functions is any less readable than a type declaration with methods. In many cases you can use both to solve the same problem, and the functional approach can be simpler.</div><div><br class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">what would be the damage if we remove local functions altogether, would we lose anything really useful? aside from the fact that "it is too late at this stage" i mean (which is appreciated).</div></div></div></div></div></blockquote><div><br class=""></div>I mean, we could remove a lot of language features without giving up turing completeness. But I’ve personally used local functions in multiple languages and found them useful. I certainly don’t see why the feature is actively harmful, which is the criteria for introducing a source breaking change in Swift 5.</div><div><br class=""></div><div>Slava</div><div><br class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class=""></div><div class="">Mike<br class=""></div><div class=""><br class=""></div></div></div></div></div>
</blockquote></div><br class=""></body></html>