[swift-evolution] Proposal: Stored properties in extensions

Tomáš Linhart tomas at linhart.me
Sat Dec 5 17:19:52 CST 2015


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áš
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151206/9a93f633/attachment.html>


More information about the swift-evolution mailing list