<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>The point here is that the escape of the inner value necessitates the (implicit) escape of the outer captured value. &nbsp;That's something closures don't have to deal with.<br><br>~Robert Widmann</div><div><br>2016/12/24 13:13、Callionica (Swift) &lt;<a href="mailto:swift-callionica@callionica.com">swift-callionica@callionica.com</a>&gt; のメッセージ:<br><br></div><blockquote type="cite"><div><div>I may be missing your point about lifetime extension problems. How would &nbsp;lifetime extension be different for captures by classes than for captures by function closures?</div><div><br><div class="gmail_quote"><div>On Sat, Dec 24, 2016 at 12:00 PM Robert Widmann &lt;<a href="mailto:devteam.codafi@gmail.com">devteam.codafi@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_msg"><div class="gmail_msg"><span class="gmail_msg"></span></div><div class="gmail_msg"><div class="gmail_msg">That still doesn't answer the lifetime extension problems.&nbsp; What is being described here is a complex extension to the lifetime of memory that is only being kept alive because of these implicit captures.&nbsp; It sounds like what you want is a member, and I'm not sure it's worth saving 5 lines to avoid that fact.</div><div class="gmail_msg"><br class="gmail_msg">~Robert Widmann</div><div class="gmail_msg"><br class="gmail_msg">2016/12/24 11:45、Callionica (Swift) via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; のメッセージ:<br class="gmail_msg"><br class="gmail_msg"></div></div></div><div class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg">Missed swift-evol in my reply</div><div class="gmail_msg"><br class="gmail_msg"><div class="gmail_quote gmail_msg"><div class="gmail_msg">---------- Forwarded message ---------<br class="gmail_msg">From: Callionica (Swift) &lt;<a href="mailto:swift-callionica@callionica.com" class="gmail_msg" target="_blank">swift-callionica@callionica.com</a>&gt;<br class="gmail_msg">Date: Sat, Dec 24, 2016 at 9:44 AM<br class="gmail_msg">Subject: Re: [swift-evolution] Should we relax restriction on closing over outer scope in class declarations?<br class="gmail_msg">To: Robert Widmann &lt;<a href="mailto:devteam.codafi@gmail.com" class="gmail_msg" target="_blank">devteam.codafi@gmail.com</a>&gt;<br class="gmail_msg"></div><br class="gmail_msg"><br class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg">These are good questions.</div><div class="gmail_msg"><br class="gmail_msg"></div>I believe Swift closures currently do implicit self-capture. I wouldn't expect that behavior to be different when capturing for classes.<div class="gmail_msg"><br class="gmail_msg"><div class="gmail_msg">If a class needs to refer to an outer self, I would expect the user to have to give the outer self a new name by assigning to a local. Same deal for referring to members in an outer class where there are members of the same name in the inner class: assign outer self to a local and refer to members through that local.</div></div></div><div class="gmail_extra gmail_msg"><br class="gmail_msg"><div class="gmail_quote gmail_msg">On Fri, Dec 23, 2016 at 10:16 AM, Robert Widmann <span class="gmail_msg">&lt;<a href="mailto:devteam.codafi@gmail.com" class="gmail_msg" target="_blank">devteam.codafi@gmail.com</a>&gt;</span> wrote:<br class="gmail_msg"><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><span class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On Dec 23, 2016, at 1:10 AM, Callionica (Swift) via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133Apple-interchange-newline gmail_msg"><div class="gmail_msg"><div class="gmail_msg">I'm certainly assuming that users have a basic understanding of scope (without that, what would be the intention behind defining the class within the function?).</div><div class="gmail_msg"><br class="gmail_msg"></div></div></blockquote><div class="gmail_msg"><br class="gmail_msg"></div></span><div class="gmail_msg">Despite its simplicity to you (given the example you’ve cited) this feature is quite an advanced extension to the current scoping rules.</div><span class="gmail_msg"><br class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg">I'm not clear on what you see as the downside of letting classes capture locals for users that are unaware of capturing.</div><div class="gmail_msg"><br class="gmail_msg"></div></div></blockquote><div class="gmail_msg"><br class="gmail_msg"></div></span><div class="gmail_msg">I’ll be blunt: This opens a gaping hole in the semantics of variable lifetimes and potentially introduces an ambiguity into resolution of the `self` keyword.&nbsp; For the former, consider a light extension to your original example that introduces a nested class:</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="gmail_msg">class</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> Outer {</span></div><span class="gmail_msg"><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp; <span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="gmail_msg">let</span>&nbsp;widgetString:&nbsp;<span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="gmail_msg">String</span>&nbsp;= createWidgetString()</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><br class="gmail_msg"></span></div></span><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="gmail_msg">&nbsp;&nbsp;<span style="color:rgb(0,132,0)" class="gmail_msg">// Initializer suppressed</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(112,61,170)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:#000000" class="gmail_msg">&nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="gmail_msg">func</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000" class="gmail_msg"> foo() -&gt; </span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">WidgetStringProvider</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000" class="gmail_msg"> {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp; &nbsp;&nbsp;</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="gmail_msg">class</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> SimpleProvider: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="gmail_msg">WidgetStringProvider</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="gmail_msg"><div style="margin:0px;line-height:normal;color:rgb(0,132,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp; &nbsp; &nbsp; // Initializer suppressed</span></div></div><span class="gmail_msg"><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="gmail_msg">func</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> provideWidgetString() -&gt; </span><span style="font-variant-ligatures:no-common-ligatures;color:#703daa" class="gmail_msg">String</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="gmail_msg">return</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> widgetString</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp; &nbsp; &nbsp; }</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp; &nbsp; }</span></div></span><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(112,61,170)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:#000000" class="gmail_msg">&nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="gmail_msg">return</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000" class="gmail_msg"> </span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">SimpleProvider</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000" class="gmail_msg">()</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp; }</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">}</span></div></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Now, from SIL’s point of view,&nbsp;<span style="font-family:Menlo;font-size:11px" class="gmail_msg">widgetString</span>&nbsp; must escape the scope it’s in and its lifetime should be extended beyond this block.&nbsp; Fine.&nbsp; But what about&nbsp;<span style="font-family:Menlo;font-size:11px" class="gmail_msg">Outer</span>?&nbsp; Because we’re returning a reference to&nbsp;<span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px" class="gmail_msg">SimpleProvider</span>&nbsp;which escapes the scope of&nbsp;<span style="font-family:Menlo;font-size:11px" class="gmail_msg">foo()</span>, and instance members of a&nbsp;<span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px" class="gmail_msg">SimpleProvider</span>&nbsp; capture outer context, this means we also have to keep&nbsp;<span style="font-family:Menlo;font-size:11px" class="gmail_msg">Outer</span>&nbsp; alive and around for destruction (perhaps at the point where&nbsp;<span style="font-family:Menlo;font-size:11px" class="gmail_msg">SimpleProvider</span>&nbsp; is destroyed?)&nbsp;</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">For the latter consider trying to explicitly reference&nbsp;<span style="font-family:Menlo;font-size:11px" class="gmail_msg">widgetString</span>&nbsp; here.&nbsp; In&nbsp;<span style="font-family:Menlo;font-size:11px" class="gmail_msg">provideWidgetString()&nbsp;</span>we &nbsp;close over&nbsp;<span style="color:rgb(186,45,162);font-family:Menlo;font-size:11px" class="gmail_msg">self&nbsp;</span>in both&nbsp;<span style="font-family:Menlo;font-size:11px" class="gmail_msg">foo()</span>&nbsp;and &nbsp;<span style="font-family:Menlo;font-size:11px" class="gmail_msg">provideWidgetString()</span>. So, if I wish to make reference to&nbsp;<font face="Menlo" class="gmail_msg"><span style="font-size:11px" class="gmail_msg">Outer’s&nbsp;</span></font><span style="color:rgb(186,45,162);font-family:Menlo;font-size:11px" class="gmail_msg">self&nbsp;</span>explicitly, how would I go about doing it?&nbsp; Given that today a nested aggregate can have members with the same identifiers as their parent, how do we know if we’re capturing them or not when they’re referenced in the inner aggregate?</div><span class="m_4938670549996583023m_1057138813566294276HOEnZb gmail_msg"><font color="#888888" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">~Robert Widmann</div></font></span><div class="gmail_msg"><div class="m_4938670549996583023m_1057138813566294276h5 gmail_msg"><br class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><div class="gmail_quote gmail_msg"><div class="gmail_msg">On Thu, Dec 22, 2016 at 11:26 PM Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" class="gmail_msg" target="_blank">xiaodi.wu@gmail.com</a>&gt; wrote:<br class="gmail_msg"></div><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Only if you're also assuming that people defining classes within functions would know about capturing. This violates the principle of progressive disclosure, since people naturally learn about functions and classes before they learn about closures and capturing.<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><div class="gmail_quote m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><div class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">On Fri, Dec 23, 2016 at 01:51 Callionica (Swift) &lt;<a href="mailto:swift-callionica@callionica.com" class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg" target="_blank">swift-callionica@callionica.com</a>&gt; wrote:<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"></div><blockquote class="gmail_quote m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">Assuming capture were allowed, people defining classes within functions who didn't want them to capture could position the class definition prior to any other code in the function so that there would be nothing to capture.&nbsp;</div><div class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><div class="gmail_quote m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><div class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">On Thu, Dec 22, 2016 at 4:13 PM Xiaodi Wu via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"></div><blockquote class="gmail_quote m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I have to agree with Michael; it seems dangerous to allow implicit capture by classes. A primary purpose (telos?) of closures is to provide this functionality, which is actually quite an advanced concept. One knows to think carefully about this when encountering a closure expression. A primary purpose of classes is to provide for encapsulation of code. Accidentally extending the lifetime of a local variable in a containing scope would be hard to notice and highly unexpected functionality. Better not to mix these things.<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><div class="gmail_quote m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><div class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">On Thu, Dec 22, 2016 at 17:54 Micah Hainline via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"></div><blockquote class="gmail_quote m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">That's exactly what I'm suggesting, the class declaration could work similarly to a closure.<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt; On Dec 22, 2016, at 4:15 PM, Michael Ilseman &lt;<a href="mailto:milseman@apple.com" class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg" target="_blank">milseman@apple.com</a>&gt; wrote:<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt; Are you asking for a class declaration to implicitly capture and extend the lifetime of local variables? That seems like something that’s better done explicitly. Perhaps it’s better to think about how to reduce the boiler plate code, e.g. better default initializers.<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt; (this is of course, additive and beyond the current scope of Swift 4 phase 1 planning)<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt; On Dec 22, 2016, at 2:39 PM, Micah Hainline via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt;<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt; Currently we allow declarations of a new class in local scope, but<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt; nothing can be referenced from the outer scope. Thus this is illegal:<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt;<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt; ```<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt; func foo() {<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt;&nbsp; let widgetString: String = createWidgetString()<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt;&nbsp; class SimpleProvider: WidgetStringProvider {<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt;&nbsp; &nbsp; &nbsp;func provideWidgetString() -&gt; String {<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; return widgetString // Illegal, defined in outer scope<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt;&nbsp; &nbsp; &nbsp;}<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt;&nbsp; }<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt;&nbsp; doThingsWithWidget(provider: WidgetStringProvider())<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt; }<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt; ```<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt;<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt; I'm trying to feel out the edges of this decision, and figure out why<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt; exactly this isn't allowed now, and how we might want to relax this in<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt; the future if possible. While not a common construct, it is a useful<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt; one.<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt;<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt; Obviously there are ways around it, very simple to create an init and<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt; a private let and do something like this:<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt;<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt; ```<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt; func foo() {<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt;&nbsp; let widgetString: String = createWidgetString()<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt;&nbsp; class SimpleProvider: WidgetStringProvider {<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt;&nbsp; &nbsp; &nbsp;private let widgetString: String<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt;<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt;&nbsp; &nbsp; &nbsp;init(widgetString: String) {<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; self.widgetString = widgetString<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt;&nbsp; &nbsp; &nbsp;}<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt;<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt;&nbsp; &nbsp; &nbsp;func provideWidgetString() -&gt; String {<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp; return widgetString // now legal, references<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt; SimpleProvider.widgetString<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt;&nbsp; &nbsp; &nbsp;}<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt;&nbsp; }<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt;&nbsp; doThingsWithWidget(provider: WidgetStringProvider(widgetString:<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt; widgetString))<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt; }<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt; ```<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt;<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt; That's boilerplate I don't want to write though, as it somewhat<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt; detracts from the readability of the structure. I'm not super<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt; interested in defending the concept of local class definitions itself,<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt; it's already allowed in the language, I'm just interested in the<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt; syntax limitation and where that line might be able to be redrawn.<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt; _______________________________________________<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt; swift-evolution mailing list<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt; <a href="mailto:swift-evolution@swift.org" class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">&gt;<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">_______________________________________________<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">swift-evolution mailing list<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><a href="mailto:swift-evolution@swift.org" class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"></blockquote></div><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">_______________________________________________<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg">swift-evolution mailing list<br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><a href="mailto:swift-evolution@swift.org" class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"><br class="m_4938670549996583023m_1057138813566294276m_-8797520062337588133gmail_msg gmail_msg"></blockquote></div></div><br class="gmail_msg"><br class="gmail_msg"></blockquote></div><br class="gmail_msg"><br class="gmail_msg"></blockquote></div></div><br class="gmail_msg"><br class="gmail_msg">_______________________________________________<br class="gmail_msg">swift-evolution mailing list<br class="gmail_msg"><a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg"></div></blockquote></div></div></div><br class="gmail_msg"></div></blockquote></div><br class="gmail_msg"></div><br class="gmail_msg"><br class="gmail_msg"></div></div><br><br></div></blockquote><blockquote type="cite" class="gmail_msg"><div class="gmail_msg"><span class="gmail_msg">_______________________________________________</span><br class="gmail_msg"><span class="gmail_msg">swift-evolution mailing list</span><br class="gmail_msg"><span class="gmail_msg"><a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a></span><br class="gmail_msg"><span class="gmail_msg"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br class="gmail_msg"></div></blockquote></div></div></blockquote></div></div>
</div></blockquote></body></html>