[swift-evolution] Proposal: Stored properties in extensions

Jacob Bandes-Storch jtbandes at gmail.com
Sat Dec 5 18:44:02 CST 2015


Sometimes it's desirable to break up a type's implementation into multiple
files, within the same module. So for this simple case, it make sense for
stored properties to be allowed (within the same module), treating them as
continuations of the original class/struct declaration with no additional
overhead.
On Sat, Dec 5, 2015 at 4:34 PM Tomáš Linhart <swift-evolution at swift.org>
wrote:

> Hello,
>
> very often, it is necessary to define stored properties in extensions. It
> is currently only possible in Swift that has access to ObjC runtime with
> associated objects (in theory it might be possible with some global
> dictionary) and it requires a lot of boilerplate. Associated objects are
> used in UIKit quite heavily so it is something that authors of frameworks
> need.
>
> It would be nice to able to create properties in extensions natively in
> Swift without need of Objective-C and without a boilerplate. These
> properties could be marked with some extra keyword/attribute so it is
> obvious they are different and they have a cost (depends on their
> implementation).
>
> What do you think?
> Tomáš
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151206/dd9928aa/attachment.html>


More information about the swift-evolution mailing list