[swift-evolution] stored properties in extensions (was: associated objects)
Paul Cantrell
cantrell at pobox.com
Fri Oct 14 20:01:18 CDT 2016
> On Oct 9, 2016, at 3:43 PM, Charles Srstka via swift-evolution <swift-evolution at swift.org> wrote:
>
> Let extensions introduce stored properties, but only in the same module as the type’s definition. Then, the compiler can just take any extensions into consideration when it’s determining the size of the type, just as if the properties had been declared in the type. Declaring stored properties on an extension outside of the type’s module results in a compiler error, exactly as today. This would, without any performance drawbacks, solve one of the big problems that people are hoping to solve via stored properties in extensions—the ability to organize members by protocol conformance.
Yes please! A big strong +1 to this from me. I can think of several specific chunks of problem code that this would clean up immensely.
Contra Karl in another message, it’s _in-module_ stored property extensions that I want most frequently. By far.
It seems to me that Charles’s idea could be introduced as its own proposal. If out-of-module stored property extensions do eventually become feasible, then Charles’s proposal is a good stepping stone. If they never do, then his proposal has done no harm.
I realize this probably falls into the post-ABI stability bucket, but I’d love to help write/support the proposal when its time comes.
Cheers,
Paul
More information about the swift-evolution
mailing list