[swift-evolution] [Proposal] Property behaviors

Joe Groff jgroff at apple.com
Tue Jan 19 17:19:33 CST 2016


> On Jan 19, 2016, at 3:10 PM, Joe Groff via swift-evolution <swift-evolution at swift.org> wrote:
> 
>> The behavior list has to match exactly (or maybe as sets?).
> 
> Are you saying that there would be no ad-hoc composition of behaviors? This seems to imply that you'd need to implement every valid combination of behaviors by hand. That's a defensible position, given that it's easy to compose behaviors like "synchronized" in the wrong order, but significantly stifles behaviors like didSet/willSet that are more likely to be order-agnostic.

Perhaps we could use '...' to distinguish composable and non-composable behaviors:

// Implementation of exactly [lazy, synchronized]
behavior var [lazy, synchronized] _: Value where Self: Synchronizable { ... }

// Implementation of 'observed' composed with any other behavior
behavior var […, observed] _: Value { ... }

-Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160119/57aac093/attachment.html>


More information about the swift-evolution mailing list