<div dir="ltr">+1. This feature would allow for a more clean approach in checking the existing state of a value. <div><br></div><div>> <span style="font-size:12.8px">Also, can a property have these observers as well as the existing ones?</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">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><br></div><div><br></div><div class="gmail_extra"><br clear="all"><div><div><div dir="ltr"><div>-Mosab Elagha<br></div></div></div></div>
<br><div class="gmail_quote">On Sun, Dec 6, 2015 at 12:11 AM, Chris Lattner via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><span><blockquote type="cite"><div>On Dec 5, 2015, at 4:00 PM, Nathan de Vries via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br><div><div style="word-wrap:break-word">It's currently possible to define either or both of the following observers on a property:<div><ul><li><i>willSet</i>, called just before the value is stored</li><li><i>didSet</i>, called immediately after the new value is stored</li></ul></div></div></div></blockquote></span><div>...</div><span><br><blockquote type="cite"><div><div style="word-wrap:break-word"><div>This would mean the following observers could be defined on a property:</div><div><div><ul><li><i>willSet</i>, called just before the value is stored</li><li><i>willChange</i>, called just before the value is stored if the value is different to the previous value</li><li><i>didSet</i>, called immediately after the new value is stored</li><li><i>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>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><div>-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">
</div>
<br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div></div>