[swift-evolution] Proposal - Allow properties in Extensions

Kevin Ballard kevin at sb.org
Fri Dec 18 18:19:55 CST 2015

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.

-Kevin Ballard

More information about the swift-evolution mailing list