<div dir="ltr">Alexander, I took your code and &quot;flattened&quot; it with what currently exists in Swift 3.  Is this not flat enough for you?<div><br></div><div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(186,45,162)"><span style="font-variant-ligatures:no-common-ligatures">struct</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"> A {</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures;white-space:pre">   </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">var</span><span style="font-variant-ligatures:no-common-ligatures"> a = </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(39,42,216)">0</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures">}</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(186,45,162)"><span style="font-variant-ligatures:no-common-ligatures">extension</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">A</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"> {</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures"><span style="white-space:pre">   </span><font color="#ba2da2">struct</font></span><span style="color:rgb(0,0,0);font-variant-ligatures:no-common-ligatures"> B {</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures;white-space:pre">      </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">var</span><span style="font-variant-ligatures:no-common-ligatures"> b = </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(209,47,27)">&quot;Bee&quot;</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures"><span style="white-space:pre">   </span>}</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures">}</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(186,45,162)"><span style="font-variant-ligatures:no-common-ligatures">extension</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">A</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">.</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">B</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"> {</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures"><span style="white-space:pre">   </span><font color="#ba2da2">struct</font></span><span style="color:rgb(0,0,0);font-variant-ligatures:no-common-ligatures"> C {</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures;white-space:pre">      </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">var</span><span style="font-variant-ligatures:no-common-ligatures"> c = </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(39,42,216)">0</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures;white-space:pre">      </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">func</span><span style="font-variant-ligatures:no-common-ligatures"> someFunc() {</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures;white-space:pre">         </span><span style="color:rgb(62,30,129);font-variant-ligatures:no-common-ligatures">print</span><span style="color:rgb(0,0,0);font-variant-ligatures:no-common-ligatures">(</span><span style="color:rgb(209,47,27);font-variant-ligatures:no-common-ligatures">&quot;something&quot;</span><span style="color:rgb(0,0,0);font-variant-ligatures:no-common-ligatures">)</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures"><span style="white-space:pre">      </span>}</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures"><span style="white-space:pre">   </span>}</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures">}</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,132,0)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">A</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">().</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">a</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"> </span><span style="font-variant-ligatures:no-common-ligatures">// print 0</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,132,0)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">A</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">.</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">B</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">().</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">b</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"> </span><span style="font-variant-ligatures:no-common-ligatures">// Print &quot;Bee&quot;</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,132,0)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">A</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">.</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">B</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">.</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">C</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">().</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(49,89,93)">someFunc</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">() </span><span style="font-variant-ligatures:no-common-ligatures">// Print &quot;something&quot;</span></p><div><br></div><div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Sun, Nov 20, 2016 at 10:23 AM Alexander Doloz via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">About scope visibility rules – I think, for now this new syntax should behave exactly like the old. What’s possible with old syntax should be possible with the new and vice versa.<br class="gmail_msg">
To Robert Widmann’s question about real situation where such syntax will be useful – right now I have a project where nested types are used. They are good for my situation, but:<br class="gmail_msg">
1. When they appear directly in the outer type I have to take extra effort to distinguish between properties and methods of outer type vs. properties and methods of inner type.<br class="gmail_msg">
2. And yes, indents. I don’t do something crazy - I have only I place where 3 types are nested. But even if there are 2 types, it becomes inconvenient to read code in the methods of the last nested type.<br class="gmail_msg">
New syntax solves this issues.<br class="gmail_msg">
&gt; 20 нояб. 2016 г., в 16:00, Rien &lt;Rien@Balancingrock.nl&gt; написал(а):<br class="gmail_msg">
&gt;<br class="gmail_msg">
&gt; Imo, it does not need extreme nested code to be useful. I find that more than 1 level of nesting tends to create obfuscation. Probably because we loose the ability to associate type C with type A. By allowing &quot;struct A.B.C&quot; it is very clear that C does indeed depend on A.<br class="gmail_msg">
&gt; However, I can already see questions coming: how to refer to struct A elements and can we introduce new scope visibility rules?<br class="gmail_msg">
&gt; Still, I like this way of programming, so for me its a +1<br class="gmail_msg">
&gt;<br class="gmail_msg">
&gt; Regards,<br class="gmail_msg">
&gt; Rien<br class="gmail_msg">
&gt;<br class="gmail_msg">
&gt; Site: <a href="http://balancingrock.nl" rel="noreferrer" class="gmail_msg" target="_blank">http://balancingrock.nl</a><br class="gmail_msg">
&gt; Blog: <a href="http://swiftrien.blogspot.com" rel="noreferrer" class="gmail_msg" target="_blank">http://swiftrien.blogspot.com</a><br class="gmail_msg">
&gt; Github: <a href="http://github.com/Swiftrien" rel="noreferrer" class="gmail_msg" target="_blank">http://github.com/Swiftrien</a><br class="gmail_msg">
&gt; Project: <a href="http://swiftfire.nl" rel="noreferrer" class="gmail_msg" target="_blank">http://swiftfire.nl</a><br class="gmail_msg">
&gt;<br class="gmail_msg">
&gt;<br class="gmail_msg">
&gt;<br class="gmail_msg">
&gt;<br class="gmail_msg">
&gt;&gt; On 20 Nov 2016, at 04:18, Robert Widmann via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br class="gmail_msg">
&gt;&gt;<br class="gmail_msg">
&gt;&gt; I think this is an interesting proposal, but I don&#39;t write enough extremely-nested code to know that it will do much more than save you some whitespace - as you say.  What situation have you run into specifically where this kind of code is both called-for and headache-inducing?<br class="gmail_msg">
&gt;&gt;<br class="gmail_msg">
&gt;&gt; ~Robert Widmann<br class="gmail_msg">
&gt;&gt;<br class="gmail_msg">
&gt;&gt; 2016/11/19 18:48、Alexander Doloz 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">
&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt; Hello, Swift community!<br class="gmail_msg">
&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt; Right now, when we declare nested types in Swift, we have to literally nest them:<br class="gmail_msg">
&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt; // Swift 3<br class="gmail_msg">
&gt;&gt;&gt; struct A {<br class="gmail_msg">
&gt;&gt;&gt;  var a = 0<br class="gmail_msg">
&gt;&gt;&gt;  struct B {<br class="gmail_msg">
&gt;&gt;&gt;      var b = 0<br class="gmail_msg">
&gt;&gt;&gt;      struct C {<br class="gmail_msg">
&gt;&gt;&gt;          var c = 0<br class="gmail_msg">
&gt;&gt;&gt;          func someFunc() {<br class="gmail_msg">
&gt;&gt;&gt;              if something {<br class="gmail_msg">
&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt;              }<br class="gmail_msg">
&gt;&gt;&gt;          }<br class="gmail_msg">
&gt;&gt;&gt;      }<br class="gmail_msg">
&gt;&gt;&gt;  }<br class="gmail_msg">
&gt;&gt;&gt; }<br class="gmail_msg">
&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt; By nesting types this way we waste amount of indents we can do without losing readability. In the example above, code inside if statement will already be far away from left border.<br class="gmail_msg">
&gt;&gt;&gt; I propose to allow do nested types like this:<br class="gmail_msg">
&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt; // Proposal<br class="gmail_msg">
&gt;&gt;&gt; struct A {<br class="gmail_msg">
&gt;&gt;&gt;  var a = 0<br class="gmail_msg">
&gt;&gt;&gt; }<br class="gmail_msg">
&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt; struct A.B {<br class="gmail_msg">
&gt;&gt;&gt;  var b = 0<br class="gmail_msg">
&gt;&gt;&gt; }<br class="gmail_msg">
&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt; struct A.B.C {<br class="gmail_msg">
&gt;&gt;&gt;  var c = 0<br class="gmail_msg">
&gt;&gt;&gt;  func someFunc() {<br class="gmail_msg">
&gt;&gt;&gt;      if something {<br class="gmail_msg">
&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt;      }<br class="gmail_msg">
&gt;&gt;&gt;  }<br class="gmail_msg">
&gt;&gt;&gt; }<br class="gmail_msg">
&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt; No more unnecessary indentation.<br class="gmail_msg">
&gt;&gt;&gt; Of course, the old way should also continue to work.<br class="gmail_msg">
&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt;<br class="gmail_msg">
&gt;&gt;&gt; _______________________________________________<br class="gmail_msg">
&gt;&gt;&gt; swift-evolution mailing list<br class="gmail_msg">
&gt;&gt;&gt; <a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
&gt;&gt;&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
&gt;&gt; _______________________________________________<br class="gmail_msg">
&gt;&gt; swift-evolution mailing list<br class="gmail_msg">
&gt;&gt; <a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
&gt;&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
&gt;<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" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
</blockquote></div>