[swift-evolution] Proposal - Allow properties in Extensions
John McCall
rjmccall at apple.com
Fri Dec 18 18:38:54 CST 2015
> On Dec 18, 2015, at 4:19 PM, Kevin Ballard <kevin at sb.org> wrote:
> On Fri, Dec 18, 2015, at 04:11 PM, John McCall wrote:
>> I think any storage-in-extensions proposal ought to be a special feature of classes; I would not support the ability to add stored properties to structs in extensions, even from within the module.
>
> Oh that's an interesting idea. My immediate reaction to "I don't want unpredictable sizes" was upon reflection something that only applies to structs. Classes are reference types already, so adding storage to them doesn't really have much consequence (structs get copied around so their size is important). Not only that, but we can already use associated objects with classes, so adding proper stored properties to them doesn't actually change the semantics of extensions, it just means avoiding the overhead of associated objects (and of value wrappers for associated objects) when the extension is part of the same module.
Right. And I think we’d also want to support some way to explicitly request the out-of-line representation even within the module.
John.
More information about the swift-evolution
mailing list