<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Yes, it that proposal is capable of expressing this, then that is how I would prefer property observers in general to work.<br><br><div>-Chris</div></div><div><br>On Dec 6, 2015, at 3:27 AM, David Hart &lt;<a href="mailto:david@hartbit.com">david@hartbit.com</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div>Chris, wouldn't that be better designed/implemented with the property delegate functionality Joe Groff is working on?<br></div><div><br>On 06 Dec 2015, at 07:52, Chris Lattner via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=utf-8"><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 5, 2015, at 10:42 PM, Mosab Elagha &lt;<a href="mailto:elagha2@illinois.edu" class="">elagha2@illinois.edu</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">+1. This feature would allow for a more clean approach in checking the existing state of a value.&nbsp;<div class=""><br class=""></div><div class="">&gt;&nbsp;<span style="font-size:12.8px" class="">Also, can a property have these observers as well as the existing ones?</span></div><div class=""><span style="font-size:12.8px" class=""><br class=""></span></div><div class=""><span style="font-size:12.8px" class="">I'm not really familiar with the implementation of the observers, but why wouldn't it be able to? Maybe didSet can precede didChange in order of execution if both are implemented, so you can have default behavior when accessing a value but certain other behavior if it has changed. Or maybe have willChange/didChange be a property that can be accessed within willSet/didSet (like oldValue).</span></div></div></div></blockquote><div><br class=""></div><div>I believe it is possible to implement, I’m just trying to give guidance on the sorts of things a formal proposal should address.</div><div><br class=""></div><div>-Chris</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class=""><br class=""></div><div class="gmail_extra"><br clear="all" class=""><div class=""><div class=""><div dir="ltr" class=""><div class="">-Mosab Elagha<br class=""></div></div></div></div>
<br class=""><div class="gmail_quote">On Sun, Dec 6, 2015 at 12:11 AM, Chris Lattner via swift-evolution <span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><br class=""><div class=""><span class=""><blockquote type="cite" class=""><div class="">On Dec 5, 2015, at 4:00 PM, Nathan de Vries via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class=""><div class=""><div style="word-wrap:break-word" class="">It's currently possible to define either or both of the following observers on a property:<div class=""><ul class=""><li class=""><i class="">willSet</i>, called just before the value is stored</li><li class=""><i class="">didSet</i>, called immediately after the new value is stored</li></ul></div></div></div></blockquote></span><div class="">...</div><span class=""><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap:break-word" class=""><div class="">This would mean the following observers could be defined on a property:</div><div class=""><div class=""><ul class=""><li class=""><i class="">willSet</i>, called just before the value is stored</li><li class=""><i class="">willChange</i>, called just before the value is stored if the value is different to the previous value</li><li class=""><i class="">didSet</i>, called immediately after the new value is stored</li><li class=""><i class="">didChange</i>,&nbsp;called immediately after the new value is stored&nbsp;if the new value is different to the previous value</li></ul></div></div></div></div></blockquote></span></div><div class="">I’m open to consider a change along these lines, but the proposal would have to be fleshed out more.&nbsp; Presumably it would only work for equatable types, right?&nbsp; Also, can a property have these observers as well as the existing ones?&nbsp; Would it be possible to add *one of* didChange or willChange - since less is better?</div><br class=""><div class="">-Chris</div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=ooyhtb0QmoWdyGi7K6ALlAws1hULkQK6RMQX9HiF5-2F8q3ZEoDp-2BSgk2CpCpSCnVkUAOUvopPtBJ8QH2q1Rn7h-2BlEA0uqa-2FzKCEBPNU-2BgS-2BUKTACFrKAk5wTl-2FEAipxTPndCVrb0cRmlSMMUOsDYhbVe5WUPXRw-2FegveUdZ7XnQVHimyqWEuc2wnBCmCEpG2xOWL62dhBJE2JcrHW78oIxXD2P3tU5ybWSO7Q8zFQEGc-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important" class="">
</div>
<br class="">_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
<br class=""></blockquote></div><br class=""></div></div>
</div></blockquote></div><br class="">
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=nE9rxSXA5G4kxsTVkgv43hXwizS3O2z60WweqomIrdgGieFu9wcIlc-2B-2F7JMQAcYNDhu6FyXg3YbpcMv-2BxVezTHpu2Gyf6jIUcPhhl25HGPALNn9QaIpeJMGjdqBbmHOEWjhzsZKS8VyzOvP-2FPC1yjW-2Bmt0uu3dv0VdJKr0-2FGZRbLiP4M1vzbKb-2B6VqoHs568wO5WCf-2B2rydDxJMuoekkCAgt7n7bjrDQwnhixyJQLpM-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;">

</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></div></blockquote></body></html>