<div dir="ltr">Alexander, I took your code and "flattened" 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)">"Bee"</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">"something"</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 "Bee"</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 "something"</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 <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> 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">
> 20 нояб. 2016 г., в 16:00, Rien <Rien@Balancingrock.nl> написал(а):<br class="gmail_msg">
><br class="gmail_msg">
> 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 "struct A.B.C" it is very clear that C does indeed depend on A.<br class="gmail_msg">
> 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">
> Still, I like this way of programming, so for me its a +1<br class="gmail_msg">
><br class="gmail_msg">
> Regards,<br class="gmail_msg">
> Rien<br class="gmail_msg">
><br class="gmail_msg">
> Site: <a href="http://balancingrock.nl" rel="noreferrer" class="gmail_msg" target="_blank">http://balancingrock.nl</a><br class="gmail_msg">
> Blog: <a href="http://swiftrien.blogspot.com" rel="noreferrer" class="gmail_msg" target="_blank">http://swiftrien.blogspot.com</a><br class="gmail_msg">
> Github: <a href="http://github.com/Swiftrien" rel="noreferrer" class="gmail_msg" target="_blank">http://github.com/Swiftrien</a><br class="gmail_msg">
> Project: <a href="http://swiftfire.nl" rel="noreferrer" class="gmail_msg" target="_blank">http://swiftfire.nl</a><br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
>> On 20 Nov 2016, at 04:18, Robert Widmann via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>> wrote:<br class="gmail_msg">
>><br class="gmail_msg">
>> I think this is an interesting proposal, but I don'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">
>><br class="gmail_msg">
>> ~Robert Widmann<br class="gmail_msg">
>><br class="gmail_msg">
>> 2016/11/19 18:48、Alexander Doloz via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>> のメッセージ:<br class="gmail_msg">
>><br class="gmail_msg">
>>> Hello, Swift community!<br class="gmail_msg">
>>><br class="gmail_msg">
>>> Right now, when we declare nested types in Swift, we have to literally nest them:<br class="gmail_msg">
>>><br class="gmail_msg">
>>> // Swift 3<br class="gmail_msg">
>>> struct A {<br class="gmail_msg">
>>> var a = 0<br class="gmail_msg">
>>> struct B {<br class="gmail_msg">
>>> var b = 0<br class="gmail_msg">
>>> struct C {<br class="gmail_msg">
>>> var c = 0<br class="gmail_msg">
>>> func someFunc() {<br class="gmail_msg">
>>> if something {<br class="gmail_msg">
>>><br class="gmail_msg">
>>> }<br class="gmail_msg">
>>> }<br class="gmail_msg">
>>> }<br class="gmail_msg">
>>> }<br class="gmail_msg">
>>> }<br class="gmail_msg">
>>><br class="gmail_msg">
>>> 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">
>>> I propose to allow do nested types like this:<br class="gmail_msg">
>>><br class="gmail_msg">
>>> // Proposal<br class="gmail_msg">
>>> struct A {<br class="gmail_msg">
>>> var a = 0<br class="gmail_msg">
>>> }<br class="gmail_msg">
>>><br class="gmail_msg">
>>> struct A.B {<br class="gmail_msg">
>>> var b = 0<br class="gmail_msg">
>>> }<br class="gmail_msg">
>>><br class="gmail_msg">
>>> struct A.B.C {<br class="gmail_msg">
>>> var c = 0<br class="gmail_msg">
>>> func someFunc() {<br class="gmail_msg">
>>> if something {<br class="gmail_msg">
>>><br class="gmail_msg">
>>> }<br class="gmail_msg">
>>> }<br class="gmail_msg">
>>> }<br class="gmail_msg">
>>><br class="gmail_msg">
>>> No more unnecessary indentation.<br class="gmail_msg">
>>> Of course, the old way should also continue to work.<br class="gmail_msg">
>>><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">
>> _______________________________________________<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">
><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>