<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="">Hi Joe,<div class=""><br class=""></div><div class=""><b class="">Why would we want to move the initialValue declaration into the body?</b> I personally like it outside because it mirrors the declaration of the actual property. </div><div class=""><br class=""></div><div class="">Also, I know the current proposal does not have a binding to get a hold of the property name. But let’s suppose that we wanted to add one as in the behavior declaration below. Notice that the right hand side of the behavior declaration (in <b class="">bold</b>) mirrors the property name, the value type and initial value respectively of a var declaration. Based on this, I find it intuitive to make the connection and understand what <font face="Consolas" class="">name</font>, <font face="Consolas" class="">Value</font> and <font face="Consolas" class="">initialValue</font> are referring to. No need to have special declarations in the body of the behavior. </div><div class=""><br class=""></div><div class="">At some point you had provided an “echo” property that showed the use of the name binding to get a hold of the property name. Then in subsequent proposals you had an _ for the place of the property name in the behavior declaration. Now I see that it’s been completely dropped. I personally liked it and think it could be useful. I probably missed in past discussions the reason why the binding for the property name was dropped. <b class="">Do you see it coming back, perhaps in a separate proposal?</b></div><div class=""><br class=""></div><div class="">As far as <font face="Consolas" class="">@lazy</font>, etc. to annotate var declarations and have them use property behaviors, I cannot think of any reasons why not. It could also be <font face="Consolas" class="">@behavior(lazy)</font> but it seems more verbose.</div><div class=""><br class=""></div><div class=""><pre style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; padding: 16px; background-color: rgb(247, 247, 247); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: normal; word-break: normal; color: rgb(51, 51, 51);" class=""><span style="font-size: 12px;" class=""><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">public</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">var</span> behavior changeObserved<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);"><</span>Value: <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Equatable</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">> </span><b class="">name: Value = initialValue </b>{
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">var</span> value <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> initialValue
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">mutating</span> accessor didChange(oldValue: Value) { }
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">get</span> {
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">return</span> value
}
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">set</span> {
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> oldValue <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> value
value <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> newValue
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">if</span> oldValue <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">!=</span> newValue {
didChange(oldValue)
}
}
}</span></pre><div class=""><br class=""></div></div><div class="">Thank you</div><div class="">Ricardo Parada</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 19, 2016, at 1:36 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=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Feb 18, 2016, at 10:09 PM, Thorsten Seitz <<a href="mailto:tseitz42@icloud.com" class="">tseitz42@icloud.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">This might be an editing problem with th examples. In the Proposed Solution the syntax is</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">public var behavior lazy<Value> = initialValue { ... }</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">which makes sense to me (though it is missing the type declaration (: Value) here.</div></div></blockquote><br class=""></div><div class="">That was a botched update on my part; I did intend to move the initialValue requirement declaration into the body:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">public var behavior lazy<Value>:Value { initialValue; ... }</div></blockquote><div class=""><br class=""></div><div class="">-Joe</div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></body></html>