[swift-evolution] Proposal - Allow properties in Extensions

Kevin Kachikian kevyk at mac.com
Tue Dec 8 23:31:37 CST 2015


I never quite understood why ObjC never implemented such a capability as it seems really useful.

I will have to defer the details however to someone else in the community as defining the semantics and implementation details are currently above my pay grade. {:~)

-Kevin



> On Dec 8, 2015, at 9:21 PM, Chris Lattner <clattner at apple.com> wrote:
> 
> 
>> On Dec 8, 2015, at 10:51 AM, Kevin Kachikian via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> 
>> I’d like to proposal to the Swift community and discuss the advantages and disadvantages of adding modifiable properties to extensions (in addition to the already existing computed properties, instance methods, subscripts, etc.):
>> 
>> extension SomeType {
>> 	
>> 	var aNewProperty: Int
>> 	var anotherVariable: String
>> 	var aThirdOne: MyStruct
> 
> IMO, this is a generally desirable thing.  It would be great to replace the need to use objc_setAssociatedObject with proper language support.  That said, the exact semantics and implementation details are unclear, so we’d need a specific detailed proposal.
> 
> -Chris

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151208/1c0c3448/attachment.html>


More information about the swift-evolution mailing list