[swift-evolution] [Review] SE-0030 Property Behaviors
Joe Groff
jgroff at apple.com
Thu Feb 11 15:10:17 CST 2016
> On Feb 11, 2016, at 12:53 PM, Chris Lattner <clattner at apple.com> wrote:
>
> I’m very curious where you stand on the syntax of the behavior decl, because this decl (as one concrete example) seems like it would be *much* nicer as:
>
> public var behavior changeObserved<Value : Equatable> {
I'd prefer not to take it as a keyword. I think we can parse it contextually between 'var' and another identifier, even though we don't do that anywhere else yet.
If we really want to keep the initial proposal modest, we could subset out the declaration syntax bikeshedding and start with the lazy implementer's approach, exposing the unpainted protocol underlying the behavior:
@property_behavior
protocol behavior {
// Type of the property instantiating the behavior.
associatedtype Value
// Backing storage for the behavior.
var storage: Value? { get set }
}
extension behavior {
// Initializer for the instantiated storage.
static func initStorage() -> Value? {
return nil
}
// Property implementation.
var value: Value {
get { ... }
set { ... }
}
}
-Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160211/2c70d854/attachment.html>
More information about the swift-evolution
mailing list