<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I’d +1 this proposal for extensions existing in the same module as the class declaration. &nbsp;However, creating new properties for classes defined in other modules would likely involve side-table lookups, and my understanding is that it has some performance implications. &nbsp;</div><div class=""><br class=""></div><div class="">In cases where you want to extend the storage of a class, consider if maybe a subclass is all you need.</div><div class=""><br class=""></div><div class="">Dan</div><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 18, 2015, at 11:42 AM, Nutchaphon Rewik via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div id="divtagdefaultwrapper" style="font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 12pt; background-color: rgb(255, 255, 255);" class=""><div style="margin-top: 0px; margin-bottom: 0px; font-family: Calibri, Arial, Helvetica, sans-serif;" class=""><span style="font-size: 12pt; white-space: pre-wrap;" class="">I only see the benefits on this.</span><br class=""></div><div id="divtagdefaultwrapper" style="font-size: 12pt; background-color: rgb(255, 255, 255);" class=""><pre style="font-family: Calibri, Arial, Helvetica, sans-serif; white-space: pre-wrap;" class=""><font face="Calibri, Arial, Helvetica, sans-serif" style="font-size: 12pt;" class=""></font></pre><pre class=""><ol style="font-family: Calibri, Arial, Helvetica, sans-serif;" class=""><li class=""><span style="font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; white-space: pre-wrap;" class="">We don't have to store all states in one file. States can be stored separately. So, we can write code in more composition style.</span><br class=""></li><li class=""><font face="Calibri, Arial, Helvetica, sans-serif" class=""><span style="white-space: pre-wrap;" class="">We can add new states to the existing type. Not just NSObject subclass with associated object.</span></font></li></ol><div class=""><font face="Calibri, Arial, Helvetica, sans-serif" class=""><span style="white-space: pre-wrap;" class=""><br class=""></span></font></div><div style="font-family: Calibri, Arial, Helvetica, sans-serif;" class=""><table width="100%" cellspacing="0" style="font-family: Calibri, Arial, Helvetica, sans-serif; white-space: normal; border-collapse: collapse; width: 935px; border: 1px solid rgb(198, 198, 198);" class=""><tbody class=""><tr class=""><td style="width: 932px; border: 1px solid rgb(198, 198, 198);" class=""><font face="Menlo" size="1" color="#BB2CA2" class=""><span style="font-size: 12px;" class="">protocol</span></font><font face="Menlo" size="1" class=""><span style="font-size: 12px;" class="">&nbsp;</span></font><font face="Menlo" size="1" color="#4F8187" class=""><span style="font-size: 12px;" class="">Incrementer</span></font><font face="Menlo" size="1" class=""><span style="font-size: 12px;" class="">{</span></font><div style="margin: 0px;" class=""><font face="Menlo" size="1" class=""><span style="font-size: 12px;" class="">&nbsp; &nbsp;&nbsp;<font color="#BB2CA2" class="">func</font>&nbsp;increase()</span></font></div><div style="margin: 0px;" class=""><font face="Menlo" size="1" class=""><span style="font-size: 12px;" class="">}<br class=""></span></font></div><div style="margin: 0px;" class=""><font face="Menlo" size="1" class=""><span style="font-size: 12px;" class=""><br class=""></span></font></div><div style="margin: 0px;" class=""><font face="Menlo" size="1" color="#4F8187" class=""><span style="font-size: 12px;" class=""><font color="#BB2CA2" class="">extension</font><font class="">&nbsp;</font>Incrementer<font class="">{</font></span></font></div><div style="margin: 0px;" class=""><font face="Menlo" size="1" color="#4F8187" class=""><span style="font-size: 12px;" class=""><font class=""><br class=""></font></span></font></div><div style="margin: 0px;" class=""><font face="Menlo" size="1" class=""><span style="font-size: 12px;" class=""><font color="red" style="color: rgb(0, 132, 0);" class="">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></font></span></font><font face="Menlo" size="1" color="#008400" class=""><span style="font-size: 12px;" class=""><font color="#BB2CA2" class="">var</font><font class="">&nbsp;count =&nbsp;</font><font color="#272AD8" class="">1&nbsp;</font></span></font><span style="color: rgb(0, 132, 0); font-family: Menlo; font-size: 12px;" class="">// allows stored properties</span></div><div style="margin: 0px;" class=""><font face="Menlo" size="1" class=""><span style="font-size: 12px;" class="">&nbsp;&nbsp; &nbsp;</span></font></div><div style="margin: 0px;" class=""><font face="Menlo" size="1" class=""><span style="font-size: 12px;" class="">&nbsp; &nbsp;&nbsp;<font color="#BB2CA2" class="">func</font>&nbsp;increase(){<br class=""></span></font></div><div style="margin: 0px;" class=""><font face="Menlo" size="1" class=""><span style="font-size: 12px;" class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<font color="#3D1D81" class="">print</font>(count)<br class=""></span></font></div><div style="margin: 0px;" class=""><font face="Menlo" size="1" class=""><span style="font-size: 12px;" class="">&nbsp; &nbsp; &nbsp; &nbsp; count = count +&nbsp;<font color="#272AD8" class="">1</font></span></font></div><div style="margin: 0px;" class=""><font face="Menlo" size="1" class=""><span style="font-size: 12px;" class="">&nbsp; &nbsp; }<br class=""></span></font></div><div style="margin: 0px;" class=""><font face="Menlo" size="1" class=""><span style="font-size: 12px;" class="">&nbsp;</span></font></div><div style="margin: 0px;" class=""><font face="Menlo" size="1" class=""><span style="font-size: 12px;" class="">}<br class=""></span></font></div><div style="margin: 0px;" class=""></div><div style="margin: 0px;" class=""><br class=""></div></td></tr></tbody></table></div></pre><pre style="font-family: Calibri, Arial, Helvetica, sans-serif; white-space: pre-wrap;" class=""><br class=""></pre><pre style="font-family: Calibri, Arial, Helvetica, sans-serif; white-space: pre-wrap;" class="">&gt;<i class=""> On Dec 8, 2015, at 10:51 AM, Kevin Kachikian via swift-evolution &lt;<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" id="LPlnk107781" title="https://lists.swift.org/mailman/listinfo/swift-evolution
Cmd+Click or tap to follow the link" class="">swift-evolution at swift.org</a>&gt; wrote:
</i>&gt;<i class=""> 
</i>&gt;<i class=""> I’d like to proposal to the Swift community and discuss the advantages and disadvantages of adding modifiable properties to extensions (in addition to the already existing computed properties, instance methods, subscripts, etc.):
</i>&gt;<i class=""> 
</i>&gt;<i class=""> extension SomeType {
</i>&gt;<i class="">         
</i>&gt;<i class="">         var aNewProperty: Int
</i>&gt;<i class="">         var anotherVariable: String
</i>&gt;<i class="">         var aThirdOne: MyStruct</i></pre></div></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=AdkfTiApI80cNEyortTzHXP9hra5wYJZ9PjV6m-2BbvoGOmeEwpqQDctNzK-2BW-2FQk7E1XgjFZXdPfEuJXamz1aWOrnp3e-2BN1aOJflE3lUOs5A7mVQLhSH9kjjTjwMurX-2Bl9sRp3-2FMn2YyJn4rwC5GCGj7iQh969SjVCczGviiAK-2FDaIpeyoeAlBTWZli9WPqzEvQEvPPSSHMYXNZ3mySyn9ZQlQOwJwJQrT3mIFEtC452o-3D" alt="" width="1" height="1" border="0" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""><span class="Apple-converted-space">&nbsp;</span>_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">swift-evolution mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:swift-evolution@swift.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">swift-evolution@swift.org</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br class=""></body></html>