[swift-evolution] [Review] SE-0030 Property Behaviors

Thorsten Seitz tseitz42 at icloud.com
Fri Feb 19 00:09:04 CST 2016

>> Am 19.02.2016 um 06:01 schrieb Curt Clifton via swift-evolution <swift-evolution at swift.org>:
>> On Feb 18, 2016, at 6:56 PM, Joe Groff via swift-evolution <swift-evolution at swift.org> wrote:
>> Based on review feedback, I've revised the declaration syntax proposal for property behaviors to be more in line with our other declaration forms, reverting to the earlier pre-review "var behavior" proposal. I've updated the proposal in swift-evolution:
>> https://github.com/apple/swift-evolution/blob/master/proposals/0030-property-behavior-decls.md
> The updated behavior declaration form is largely an improvement. 

Yes, I prefer it as well.

> With the placeholder for binding the name of the attributed property gone from the grammar, I wonder if you’ve given any thought to how that binding might be done. I recognize that the binding is left for future work, but would hate to see my pet feature painted into a corner.
> I find the naked `initialValue` “declaration" quite odd. It’s not exactly a declaration

This might be an editing problem with th examples. In the Proposed Solution the syntax is

public var behavior lazy<Value> = initialValue { ... }

which makes sense to me (though it is missing the type declaration (: Value) here.

> even. What are the implications for parsing? If we’re already willing to special case`initialValue` in the parser in this context, perhaps we could introduce a binding list instead, like:
> ```
> public var behavior lazy<Value>: Value {
>   // Behaviors can bind the property's initializer expression with a
>   // binding declaration.
>   bind initialValue
>> ```
> Besides eliminating the odd naked “declaration”, this has the added advantage that it could be extended to `bind initialValue, propertyName`. :-)

Couldn't we just add a name by introducing an accessor to be implemented by the user of a property?
Alternatively the syntax could be extended to

public var behavior(name: String) lazy<Value>...

but I don't think that is necessary.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160219/2bc2b18c/attachment.html>

More information about the swift-evolution mailing list