<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 5, 2015, at 10:42 PM, Mosab Elagha <<a href="mailto:elagha2@illinois.edu" class="">elagha2@illinois.edu</a>> 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. <div class=""><br class=""></div><div class="">> <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=""><<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>></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 <<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>> 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>, called immediately after the new value is stored 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. Presumably it would only work for equatable types, right? Also, can a property have these observers as well as the existing ones? 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=""></body></html>