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

Curt Clifton curt at curtclifton.net
Thu Feb 18 23:01:12 CST 2016

> 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 <https://github.com/apple/swift-evolution/blob/master/proposals/0030-property-behavior-decls.md>
The updated behavior declaration form is largely an improvement. 

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 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`. :-)

Also, the initialValue in the “Proposed Solution” section doesn’t match the naked syntax used throughout the Examples section.

> In discussion with the core team, we've also strongly come in favor of applying behaviors to properties using attribute syntax, e.g.:
> @lazy var x = 111
> @delayed var x: Int
> They're definitely attribute-like, and we think it makes sense for behaviors to be the first of hopefully many kinds of user-defined behaviors. What do you all think of this direction?

I think this is an excellent direction. Would we also use @ syntax for accessing property-supplied members, like `a at runcible.x`?


Curt Clifton, PhD
Software Engineer
The Omni Group

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160218/00aec368/attachment.html>

More information about the swift-evolution mailing list