<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">On Feb 19, 2016, at 12:01 AM, Curt Clifton via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Feb 18, 2016, at 6:56 PM, Joe Groff via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">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:<div class=""><br class=""></div><blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;"><div class=""><a href="https://github.com/apple/swift-evolution/blob/master/proposals/0030-property-behavior-decls.md" class="">https://github.com/apple/swift-evolution/blob/master/proposals/0030-property-behavior-decls.md</a></div></blockquote></div></div></blockquote><div class=""><br class=""></div><div class="">The updated behavior declaration form is largely an improvement. </div><div class=""><br class=""></div><div class="">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.</div><div class=""><br class=""></div><div class="">I find the naked `initialValue` “declaration" quite odd. It’s not exactly a declaration even.</div></div></blockquote><div class=""><br class=""></div>I find the 'initialValue' declaration a little odd as well. Also, when looking at the proposal, most of the behaviors have one of these declared. For a given property with multiple behaviors, we are holding onto duplicate data. Perhaps I'm just misunderstanding the proposal?<div class=""><br class=""><blockquote type="cite" class=""><div class="">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:</div><div class=""><br class=""></div><div class="">```</div><div class=""><div class="">public var behavior lazy<Value>: Value {</div><div class=""> // Behaviors can bind the property's initializer expression with a</div><div class=""> // binding declaration.</div><div class=""> bind initialValue</div><div class=""> …</div></div><div class="">```</div></blockquote><div class=""><br class=""></div>Is this binding like a reference to the actual property? I think it would be awesome if there were a way for the behavior's 'value' property to bind or reference the property to which the behavior is being applied. Then, there isn't any duplicate data, and the behavior is actually acting on the property. Personally, a given behavior acting on the property I have assigned it to is what I am expecting to happen. Not a behavior that works on some mysterious value that then sets the property. </div><div class=""><br class=""></div><div class="">To achieve this, could we have behaviors decide how a property is fundamentally treated instead of add functionality? Meaning a behavior such as lazy accesses the actual property value when doing its operations. At initialization of the property, lazy allows for reservation of space for the properties type, but doesn't not assign a value to it until the property gets called on. </div><div class=""><br class=""></div><div class="">In a sense we'd be making a property/computed property hybrid where the computer part is defined by the user's defined behavior. </div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="">Besides eliminating the odd naked “declaration”, this has the added advantage that it could be extended to `bind initialValue, propertyName`. :-)</div><div class=""><br class=""></div><div class="">Also, the initialValue in the “Proposed Solution” section doesn’t match the naked syntax used throughout the Examples section.</div><br class=""><blockquote type="cite" class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">In discussion with the core team, we've also strongly come in favor of applying behaviors to properties using attribute syntax, e.g.:<div class=""><br class=""></div><blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;"><div class="">@lazy var x = 111</div><div class="">@delayed var x: Int</div><div class=""><br class=""></div></blockquote>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?</div></div></blockquote><div class=""><br class=""></div><div class="">I think this is an excellent direction. Would we also use @ syntax for accessing property-supplied members, like `<a href="mailto:a@runcible.x" class="">a@runcible.x</a>`?</div><div class=""><br class=""></div><div class=""><div class="">Cheers,</div><div class=""><br class=""></div><div class="">Curt</div><div class="">-----------------------------------------------------------------------------</div><div class="">Curt Clifton, PhD</div><div class="">Software Engineer</div><div class="">The Omni Group</div><div class=""><a href="http://www.curtclifton.net" class="">www.curtclifton.net</a></div><div class=""><br class=""></div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div></blockquote><blockquote type="cite" class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></blockquote></div></body></html>