<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><p style="margin: 0px; line-height: normal; font-family: '.SF UI Text'; color: rgb(69, 69, 69);"><span style="font-family: '.SFUIText-Semibold'; font-weight: bold; font-size: 17pt;">class A {</span></p>
<p style="margin: 0px; line-height: normal; font-family: '.SF UI Text'; color: rgb(69, 69, 69);"><span style="font-family: '.SFUIText-Semibold'; font-weight: bold; font-size: 17pt;"> func foo() -> ()->String {</span></p>
<p style="margin: 0px; line-height: normal; font-family: '.SF UI Text'; color: rgb(69, 69, 69);"><span style="font-family: '.SFUIText-Semibold'; font-weight: bold; font-size: 17pt;"> func local() -> String { [weak self] in </span></p>
<p style="margin: 0px; line-height: normal; font-family: '.SF UI Text'; color: rgb(69, 69, 69);"><span style="font-family: '.SFUIText-Semibold'; font-weight: bold; font-size: 17pt;"> return "foo \(self.i)"</span></p>
<p style="margin: 0px; line-height: normal; font-family: '.SF UI Text'; color: rgb(69, 69, 69);"><span style="font-family: '.SFUIText-Semibold'; font-weight: bold; font-size: 17pt;"> }</span></p>
<p style="margin: 0px; line-height: normal; font-family: '.SF UI Text'; color: rgb(69, 69, 69);"><span style="font-family: '.SFUIText-Semibold'; font-weight: bold; font-size: 17pt;"> return local</span></p>
<p style="margin: 0px; line-height: normal; font-family: '.SF UI Text'; color: rgb(69, 69, 69);"><span style="font-family: '.SFUIText-Semibold'; font-weight: bold; font-size: 17pt;"> }</span></p></div><div>...</div><div><br></div><div>compares well with this...</div><div><br></div><div><p style="margin: 0px; line-height: normal; font-family: '.SF UI Text'; color: rgb(69, 69, 69);"><span style="font-family: '.SFUIText-Semibold'; font-weight: bold; font-size: 17pt;">class A {</span></p>
<p style="margin: 0px; line-height: normal; font-family: '.SF UI Text'; color: rgb(69, 69, 69);"><span style="font-family: '.SFUIText-Semibold'; font-weight: bold; font-size: 17pt;"> func foo() -> ()->String {</span></p>
<p style="margin: 0px; line-height: normal; font-family: '.SF UI Text'; color: rgb(69, 69, 69);"><span style="font-family: '.SFUIText-Semibold'; font-weight: bold; font-size: 17pt;"> let local : () -> String = { [weak self] in</span></p>
<p style="margin: 0px; line-height: normal; font-family: '.SF UI Text'; color: rgb(69, 69, 69);"><span style="font-family: '.SFUIText-Semibold'; font-weight: bold; font-size: 17pt;"> return "foo \(self?.i)"</span></p>
<p style="margin: 0px; line-height: normal; font-family: '.SF UI Text'; color: rgb(69, 69, 69);"><span style="font-family: '.SFUIText-Semibold'; font-weight: bold; font-size: 17pt;"> }</span></p>
<p style="margin: 0px; line-height: normal; font-family: '.SF UI Text'; color: rgb(69, 69, 69);"><span style="font-family: '.SFUIText-Semibold'; font-weight: bold; font-size: 17pt;"> return local</span></p>
<p style="margin: 0px; line-height: normal; font-family: '.SF UI Text'; color: rgb(69, 69, 69);"><span style="font-family: '.SFUIText-Semibold'; font-weight: bold; font-size: 17pt;"> }</span></p>
<p style="margin: 0px; line-height: normal; font-family: '.SF UI Text'; color: rgb(69, 69, 69);"><span style="font-family: '.SFUIText-Semibold'; font-weight: bold; font-size: 17pt;"> func foo2() -> ()->String {</span></p>
<p style="margin: 0px; line-height: normal; font-family: '.SF UI Text'; color: rgb(69, 69, 69);"><span style="font-family: '.SFUIText-Semibold'; font-weight: bold; font-size: 17pt;"> let local : () -> String = {</span></p>
<p style="margin: 0px; line-height: normal; font-family: '.SF UI Text'; color: rgb(69, 69, 69);"><span style="font-family: '.SFUIText-Semibold'; font-weight: bold; font-size: 17pt;"> return "foo2 \(self.i)"</span></p>
<p style="margin: 0px; line-height: normal; font-family: '.SF UI Text'; color: rgb(69, 69, 69);"><span style="font-family: '.SFUIText-Semibold'; font-weight: bold; font-size: 17pt;"> }</span></p>
<p style="margin: 0px; line-height: normal; font-family: '.SF UI Text'; color: rgb(69, 69, 69);"><span style="font-family: '.SFUIText-Semibold'; font-weight: bold; font-size: 17pt;"> return local</span></p>
<p style="margin: 0px; line-height: normal; font-family: '.SF UI Text'; color: rgb(69, 69, 69);"><span style="font-family: '.SFUIText-Semibold'; font-weight: bold; font-size: 17pt;"> }</span></p>
<p style="margin: 0px; line-height: normal; font-family: '.SF UI Text'; color: rgb(69, 69, 69);"><span style="font-family: '.SFUIText-Semibold'; font-weight: bold; font-size: 17pt;"> let i : Int</span></p>
<p style="margin: 0px; line-height: normal; font-family: '.SF UI Text'; color: rgb(69, 69, 69);"><span style="font-family: '.SFUIText-Semibold'; font-weight: bold; font-size: 17pt;"> init(_ i: Int) { self.i = i }</span></p>
<p style="margin: 0px; line-height: normal; font-family: '.SF UI Text'; color: rgb(69, 69, 69);"><span style="font-family: '.SFUIText-Semibold'; font-weight: bold; font-size: 17pt;">}</span></p>
<p style="margin: 0px; line-height: normal; font-family: '.SF UI Text'; color: rgb(69, 69, 69);"><span style="font-family: '.SFUIText-Semibold'; font-weight: bold; font-size: 17pt;">var a = A(2)</span></p>
<p style="margin: 0px; line-height: normal; font-family: '.SF UI Text'; color: rgb(69, 69, 69);"><span style="font-family: '.SFUIText-Semibold'; font-weight: bold; font-size: 17pt;">let b = a.foo()</span></p>
<p style="margin: 0px; line-height: normal; font-family: '.SF UI Text'; color: rgb(69, 69, 69);"><span style="font-family: '.SFUIText-Semibold'; font-weight: bold; font-size: 17pt;">a = A(4)</span></p>
<p style="margin: 0px; line-height: normal; font-family: '.SF UI Text'; color: rgb(69, 69, 69);"><span style="font-family: '.SFUIText-Semibold'; font-weight: bold; font-size: 17pt;">print(b()) // prints "foo nil"</span></p>
<p style="margin: 0px; line-height: normal; font-family: '.SF UI Text'; color: rgb(69, 69, 69); min-height: 20.3px;"><span style="font-family: '.SFUIText-Semibold'; font-weight: bold; font-size: 17pt;"></span><br></p>
<p style="margin: 0px; line-height: normal; font-family: '.SF UI Text'; color: rgb(69, 69, 69);"><span style="font-family: '.SFUIText-Semibold'; font-weight: bold; font-size: 17pt;">let b2 = a.foo2()</span></p>
<p style="margin: 0px; line-height: normal; font-family: '.SF UI Text'; color: rgb(69, 69, 69);"><span style="font-family: '.SFUIText-Semibold'; font-weight: bold; font-size: 17pt;">a = A(6)</span></p>
<p style="margin: 0px; line-height: normal; font-family: '.SF UI Text'; color: rgb(69, 69, 69);"><span style="font-family: '.SFUIText-Semibold'; font-weight: bold; font-size: 17pt;">print(b2()) // prints "foo2 4"</span></p><br><div><span style="background-color: rgba(255, 255, 255, 0);">--<br>C. Keith Ray</span><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="background-color: rgba(255, 255, 255, 0);">* <a href="https://leanpub.com/wepntk">https://leanpub.com/wepntk</a> <- buy my book?<br>* </span><a href="http://www.thirdfoundationsw.com/keith_ray_resume_2014_long.pdf">http://www.thirdfoundationsw.com/keith_ray_resume_2014_long.pdf</a><span style="background-color: rgba(255, 255, 255, 0);"><br>* <a href="http://agilesolutionspace.blogspot.com/">http://agilesolutionspace.blogspot.com/</a></span></div></div></div><div><br>On Oct 25, 2017, at 1:21 PM, David Hart via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br><br></div><blockquote type="cite"><div><span class="pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">class</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(111, 66, 193);">A</span> {
<span class="pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(111, 66, 193);">foo</span>() {
<span class="pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(111, 66, 193);">local</span>() <span class="pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">-></span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 92, 197);">Int</span> { [<span class="pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">weak</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 92, 197);">self</span>] <span class="pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">in</span>
}
}
}</div></blockquote></body></html>