<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="">Of course, I meaned</div><div class=""><br class=""></div><div class="">&nbsp;set(newValue foo: valueType) {</div><div class=""><br class=""></div><div class="">}</div><br class=""><div><blockquote type="cite" class=""><div class="">Le 4 déc. 2016 à 09:56, Jean-Daniel via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; a écrit :</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">If you want to go to the side of consistency, why not just require the standard method syntax like any other place ?</div><div class=""><br class=""></div><div class="">set(foo newValue: valueType) {</div><div class=""><br class=""></div><div class="">}</div><div class=""><br class=""></div><div class="">So old/newValue will become a parameter label.</div><div class=""><br class=""></div><br class=""><div class=""><blockquote type="cite" class=""><div class="">Le 4 déc. 2016 à 04:06, Erica Sadun via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; a écrit :</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=""><div class="">[Original pitch:&nbsp;<a href="https://gist.github.com/erica/f5c58c689a6f479606c6158077c1962b" class="">https://gist.github.com/erica/f5c58c689a6f479606c6158077c1962b</a>]</div><div class=""><br class=""></div><div class="">GENERAL FEEDBACK</div><div class=""><br class=""></div><div class="">I received a gratifying amount of feedback about my pitch here, on Twitter,&nbsp;</div><div class="">through email, on several Slack channels, and on IRC. I wanted to summarize&nbsp;</div><div class="">the feedback, to start a new round of discussion.</div><div class=""><br class=""></div><div class="">* A majority of respondents believe the current feature is incorrectly designed&nbsp;</div><div class="">&nbsp; and that this is our best opportunity to change it.</div><div class="">* A majority of respondents disagree on *how* it should be changed.</div><div class=""><br class=""></div><div class=""><div class="">Before I commit to the (non-trivial) effort of pushing on this, I'd like to know if any&nbsp;</div><div class="">of the core team can chime in on the "preferred" design. Thank you.</div></div><div class=""><br class=""></div><div class="">BUG REPORT</div><div class=""><br class=""></div><div class="">The notion that the compiler should check for&nbsp;`set(oldValue)`, `willSet(oldValue)`,&nbsp;</div><div class="">and `didSet(newValue)` and emit warnings or errors had pretty much &nbsp;universal</div><div class="">support. I have submitted <a href="https://bugs.swift.org/browse/SR-3310" class="">https://bugs.swift.org/browse/SR-3310</a>&nbsp;to address</div><div class="">this, regardless of whether the syntax changes or not.</div><div class=""><br class=""></div><div class="">MENTIONING NAMES</div><div class=""><br class=""></div><div class="">A majority of respondents prefer that argument names always be mentioned,&nbsp;</div><div class="">whether or not they *can* be omitted. Consensus is that it's unSwifty</div><div class="">to use pre-built `newValue` and `oldValue` arguments without mentioning</div><div class="">them first.</div><div class=""><br class=""></div><div class="">* The current system violates the principle of clarity.&nbsp;</div><div class="">* It adds too much magic (<a href="https://en.wikipedia.org/wiki/Magic_(programming))" class="">https://en.wikipedia.org/wiki/Magic_(programming))</a>&nbsp;</div><div class="">&nbsp; at the point of use.&nbsp;</div><div class="">* It is inconsistent with the binding of variable names in closures.</div><div class=""><br class=""></div><div class="">My original design, which I chose to provide the least impact on the compiler and&nbsp;</div><div class="">existing code, was the least popular option.</div><div class=""><br class=""></div><div class="">PREFERRED DESIGN</div><div class=""><br class=""></div><div class="">The most popular design is that setters and property observers follow closures</div><div class="">syntax, &nbsp;namely that the old value and new value arguments be passed as $0,&nbsp;</div><div class="">and assignable using `name in`. Under this design, a setter looks like:</div><div class=""><br class=""></div><div class="">```</div><div class="">set { newValue in ... } // or</div><div class="">set { somethingElse in ... } // or</div><div class="">set { use $0 here }</div><div class="">```</div><div class="">Swift loses the "magic" newValue and oldValue, but any developer who</div><div class="">normally prefers to mention the name before use has a simple, visible</div><div class="">and easy way to retain that clarity.&nbsp;</div><div class=""><br class=""></div><div class="">* Mirrors closure syntax</div><div class="">* Easy to use</div><div class="">* Loses magic names</div><div class="">* Encourages documenting names in context</div><div class=""><br class=""></div><div class="">"NO CHANGE"</div><div class=""><br class=""></div><div class="">The second most popular design is "leave things as they are" (but implement the bug</div><div class="">report.) Developers with good style habits will use mandatory `newValue` and `oldValue`</div><div class="">names in their setter and observer declarations. No proposal is needed, and the bug</div><div class="">report guards against potential errors.</div><div class=""><br class=""></div><div class="">I would appreciate knowing whether the core team feels that the support for "no change",</div><div class="">even from a smaller group of developers, disqualifies this issue from the high bar of Phase 1.</div><div class=""><br class=""></div><div class="">(This group also included the most developers who self-reported that they did not</div><div class="">&nbsp;use the override feature.)</div><div class=""><br class=""></div><div class="">REMOVING OVERRIDES</div><div class=""><br class=""></div><div class="">A third design entirely loses the ability to override variables or mention their names.&nbsp;</div><div class="">This was in fact my *original* original design that I did not submit after sufficient&nbsp;</div><div class="">devs told me they wanted to always spell out magic argument names.&nbsp;</div><div class=""><br class=""></div><div class="">RIGHT NAMES ONLY</div><div class=""><br class=""></div><div class="">Finally, the least popular design is my original pitch. (Only allow the "right" names,</div><div class="">and allow them to be omitted.) This design has the least impact on the language,&nbsp;</div><div class="">causes the least breaking for most use-cases, and allows most pro coders to continue</div><div class="">using the "mention all names" approach.</div><div class=""><br class=""></div><div class="">UPDATING PROPOSAL</div><div class=""><br class=""></div><div class="">I am happy to update the proposal for the "closure-like" design. I believe there *was*</div><div class="">reasonable consensus that the current system is out of step with Swift's design goals</div><div class="">to push forward. However, I want this to go through another round of feedback.</div><div class=""><br class=""></div><div class="">Thank you in advance for your comments. If this does move forward to a proposal, it</div><div class="">must be discussed and decided in the first phase of Swift 4 as the change *is* breaking.</div><div class=""><br class=""></div><div class="">-- Erica</div><div class=""><br class=""></div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 1, 2016, at 10:22 PM, Derrick Ho &lt;<a href="mailto:wh1pch81n@gmail.com" class="">wh1pch81n@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class="">I like this proposal!<br class=""><br class="">+1<br class=""><br class=""></div></blockquote></div><br class=""></div>_______________________________________________<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><br class=""></div></blockquote></div><br class=""></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=""></body></html>