<div dir="ltr"><div>Hello Karl,</div><div><br></div>Don&#39;t you think stored properties in extensions would encourage the kind of code you talked about. I believe may you&#39;re doing it while understanding it&#39;s implications and also accepting the fact that it&#39;s not easy to write UI code in a modular way, but do we want everyone to think like this? Should we accept defeat on the face of this problem that there&#39;s no way to write UI code in a modular way where we don&#39;t have to put everything in one massive view controller?<div><br></div><div>I feel we would be just raising our hands up if we do it this way</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 24 March 2017 at 16:49, Karl Wagner via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><blockquote type="cite"><div><div class="h5"><div>On 24 Mar 2017, at 10:50, Haravikk via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_-2051618511489866058Apple-interchange-newline"></div></div><div><div><div class="h5"><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><blockquote type="cite"><div><br class="m_-2051618511489866058Apple-interchange-newline">On 23 Mar 2017, at 21:10, Vladimir.S via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_-2051618511489866058Apple-interchange-newline"><div><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">On 23.03.2017 21:21, Matthew Johnson via swift-evolution wrote:</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><blockquote type="cite" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br><blockquote type="cite">On Mar 23, 2017, at 1:12 PM, Charles Srstka via swift-evolution<br>&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br><br>MOTIVATION:<br><br>In current Swift, a pattern has emerged among some developers, in<br>order to logically group parts of a class or struct’s declaration,<br>particularly around protocols:<br></blockquote></blockquote><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">&gt;&gt; ...</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><blockquote type="cite" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><blockquote type="cite"><br>What do you think?<br></blockquote><br>If we wanted to allow code like this to be written we wouldn’t need a<br>new keyword to do it.  You are proposing two things here:<br><br>1) Allow stored properties in same-module extensions.  This has been<br>discussed in the past and is a possibility, but I suspect it is not in<br>scope for consideration during Swift 4.<br></blockquote><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">Are we really expect to have stored properties in same-module extensions?</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">As I remember, there a lot of questions were raised during discussions so for some reason *I* had a feeling that we should not expect this happens in near feature. Probably I missed something.</span></div></blockquote><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">I can see why some people might want to do stored properties in extensions to structure things, but personally I quite like the lack of flexibility as it encourages the initial type declaration to focus on what a type<span class="m_-2051618511489866058Apple-converted-space"> </span><b>contains</b>, while extensions focus on what it<span class="m_-2051618511489866058Apple-converted-space"> </span><b>does</b>. I&#39;ve really taken to that style, as I now almost never declare methods or computed properties in an initial type declaration, unless it&#39;s a very simple one; instead doing all my methods and protocol conformances in their own extensions.</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">i.e- I quite like that by the time you&#39;ve finished your type declaration you have finalised what its size will be, and nothing else can change that, spreading it out feels like it could make that more confusing. It also IMO helps to encourage you to keep a type&#39;s contents fairly simple, as you can see in one place if you&#39;ve made it very complicated.</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">I suppose there&#39;s an argument for having the freedom to do it however you want, but I don&#39;t think spreading out across a module is a good idea; unless we&#39;re assuming that module in this context applies like in other proposals, where fileprivate is a &quot;module&quot; with only one file.</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">I dunno, I just think that as a pattern the current requirement to keep stored properties within a type declaration enforces some good practices. I found it a bit jarring at first too, but after adapting to the type + extensions style I find I actually really like doing things that way.</div></div></div><span class=""><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">______________________________<wbr>_________________</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">swift-evolution mailing list</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="mailto:swift-evolution@swift.org" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">swift-evolution@swift.org</a><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a></span></div></blockquote></div><br><div><br></div><div>If you have a complex class (especially in UI code), you sometimes don’t really care about the size of the class and would prefer data to be grouped in broader functional groups. For example, I might like my toolbar-related iVars to be in one extension, and my datasource-related iVars in another, maybe with a couple of protocol conformances with require the odd state variable.</div><div><br></div><div>Requiring all of the stored properties live in the initial declaration means that the code is ultimately less clear: instead of being locally-declared (and perhaps even privately-scoped), the variable is now thousands of lines away from the only place I want to access it directly and visible throughout my implementation for me to one day muck up its state.</div><div><br></div><div>Allowing stored extensions within the same file seems like a good compromise to me, especially if its “trivial” to implement ;) Perhaps we could require such types to have some special annotation or magic “ExtensionVariables” item, for the benefit of readability? Just trying to find what you’d feel would be acceptable.</div><div><br></div><div>- Karl</div></div><br>______________________________<wbr>_________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><font color="#999999" size="2" face="georgia, serif"><i>Pranshu Goyal</i></font><div><font color="#999999" size="2" face="times new roman, serif"><i>iOS Developer</i></font></div><div><font color="#999999" size="2" face="times new roman, serif"><i>tlkn</i></font></div></div></div>
</div>