<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">[Original pitch: <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, </div><div class="">through email, on several Slack channels, and on IRC. I wanted to summarize </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 </div><div class=""> 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 </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 `set(oldValue)`, `willSet(oldValue)`, </div><div class="">and `didSet(newValue)` and emit warnings or errors had pretty much 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> 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, </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. </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> </div><div class=""> at the point of use. </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 </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, namely that the old value and new value arguments be passed as $0, </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. </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=""> 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. </div><div class="">This was in fact my *original* original design that I did not submit after sufficient </div><div class="">devs told me they wanted to always spell out magic argument names. </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, </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><blockquote type="cite" class=""><div class="">On Dec 1, 2016, at 10:22 PM, Derrick Ho <<a href="mailto:wh1pch81n@gmail.com" class="">wh1pch81n@gmail.com</a>> 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=""></body></html>