<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 May 4, 2016, at 1:22 PM, Erica Sadun via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" 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="" dir="auto"><div class="">Here is a real world example of where I use defaulted parameters:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class=""><div style="margin: 0px; line-height: normal;" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">public</span><span style="" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">extension</span><span style="" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">UIView</span><span style="" class=""> {</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">public</span><span style="" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">convenience</span><span style="" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">init</span><span style="" class="">(</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures;" class="">_</span><span style="font-variant-ligatures: no-common-ligatures" class=""> w: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">CGFloat</span><span style="font-variant-ligatures: no-common-ligatures" class="">,</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures;" class="">_</span><span style="font-variant-ligatures: no-common-ligatures" class=""> h: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">CGFloat</span><span style="font-variant-ligatures: no-common-ligatures" class="">,</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> position: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">CGPoint</span><span style="font-variant-ligatures: no-common-ligatures" class=""> = .zero,</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> backgroundColor: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">UIColor</span><span style="font-variant-ligatures: no-common-ligatures" class=""> = </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">UIColor</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">whiteColor</span><span style="font-variant-ligatures: no-common-ligatures" class="">(),</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> translucency alpha: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">CGFloat</span><span style="font-variant-ligatures: no-common-ligatures" class=""> = </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">1.0</span><span style="font-variant-ligatures: no-common-ligatures" class="">,</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> borderWidth: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">CGFloat</span><span style="font-variant-ligatures: no-common-ligatures" class=""> = </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0.0</span><span style="font-variant-ligatures: no-common-ligatures" class="">,</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> borderColor: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">UIColor</span><span style="font-variant-ligatures: no-common-ligatures" class=""> = </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">UIColor</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">blackColor</span><span style="font-variant-ligatures: no-common-ligatures" class="">(),</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> cornerRadius: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">CGFloat</span><span style="font-variant-ligatures: no-common-ligatures" class=""> = </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0.0</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> ){</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures;" class="">self</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures;" class="">init</span><span style="font-variant-ligatures: no-common-ligatures" class="">(frame: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">CGRect</span><span style="font-variant-ligatures: no-common-ligatures" class="">(x: position.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">x</span><span style="font-variant-ligatures: no-common-ligatures" class="">, y: position.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">y</span><span style="font-variant-ligatures: no-common-ligatures" class="">, width: w, height: h))</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures;" class="">self</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">backgroundColor</span><span style="font-variant-ligatures: no-common-ligatures" class=""> = backgroundColor.</span><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">colorWithAlphaComponent</span><span style="font-variant-ligatures: no-common-ligatures" class="">(alpha)</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures;" class="">self</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">layer</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">borderWidth</span><span style="font-variant-ligatures: no-common-ligatures" class=""> = borderWidth</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures;" class="">self</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">layer</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">borderColor</span><span style="font-variant-ligatures: no-common-ligatures" class=""> = borderColor.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">CGColor</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures;" class="">self</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">layer</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">cornerRadius</span><span style="font-variant-ligatures: no-common-ligatures" class=""> = cornerRadius</span></div><div style="margin: 0px; line-height: normal; color: rgb(112, 61, 170);" class=""><span style="" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span><span style="" class="">.</span><span style="font-variant-ligatures: no-common-ligatures" class="">translatesAutoresizingMaskIntoConstraints</span><span style="" class=""> = </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">false</span></div><div style="margin: 0px; line-height: normal;" class=""> }</div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div></div><div class=""><br class=""></div></div></div><div class=""><br class=""></div><div class="">It's not a beautiful initializer or aspirational code. It <i class="">is</i> convenient for putting together flexible views in playgrounds. This utility controls the axes I typically want to tweak for view creation:</div><div class=""><br class=""></div><div class="">* How big is it (w, h)</div><div class="">* Where is it? (position, if used, for example, as a subview)</div><div class="">* What color is it? Is the color solid or translucent? (backgroundColor, translucency)</div><div class="">* Does it have a border? and if so, how wide and what color? (borderWidth, borderColor)</div><div class="">* Are the corners rounded and to what degree? (cornerRadius)</div><div class=""><br class=""></div><div class="">The reason I present this example is that while there are relationships between some of the defaulted values, there is <b class="">absolutely no inherent order</b> to those groups. When putting together a view, I may later decide to add, for example, the border. Should I have to know that the border must appear before any background color settings?</div></div></div></blockquote><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="" dir="auto"><div class=""><br class=""></div><div class="">Having to figure out <i class="">where</i> a previously defaulted value should be inserted when adding an explicit setting imposes an undue burden on the programmer, reduces flexibility during experimentation, and removes one of the neatest Swift features. For this reason, I vote <b class="">no</b> on the proposal. By rejecting this proposal, Swift retains a flexibility that defers to the programmer, placing the programmer's needs before any benefits that may accrue to the compiler.</div></div></div></blockquote><div><br class=""></div><div><div>Thanks for bringing a concrete example to the discussion Erica. This is a good example of the memberwise initializer use case for reordering. This is exactly the kind of cognitive burden I mentioned in my review. This burden is also present for *any* function which might have “options” with defaults, it does not just apply to initializers.</div><div><br class=""></div><div>I’m really glad you discussed code evolution as I was only thinking about writing new code and reading code when considering this proposal. I think you have swayed me firmly into the -1 camp unless it can be demonstrated that there are many existing APIs which are negatively impacted at the call site by reordering of their defaulted arguments. Adding and removing “options” from a call to an initializer or function such as this is not an uncommon thing to do (at least in some domains such as apps), and as you point out facilitating experimentation is a big part of what Swift is about.</div></div><div><br class=""></div><div>IMO this example also demonstrates why it may also be desirable to also allow reordering of “w” and “h” as there really is no inherent order present in those either and enforcing an order does not add clarity in this case. That said, the case for enforcing order here is stronger than the one for defaulted arguments, partly because they always *must* be present and are therefore not as subject to the “experimentation” burden you describe.</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="" dir="auto"><div class=""><br class=""></div><div class="">I have followed the discussion. I believe it goes <b class="">against</b> the general Swift philosophy. And while the change being proposed <b class="">is</b> significant to be part of a formal language review process, I think adopting it would be the wrong thing to do.</div></div></div></blockquote></div><div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="" dir="auto"><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 May 3, 2016, at 9:52 PM, Chris Lattner via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Hello Swift community,<br class=""><br class="">The review of "SE-0060: Enforcing order of defaulted parameters" begins now and runs through May 9. The proposal is available here:<br class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">        </span><a href="https://github.com/apple/swift-evolution/blob/master/proposals/0060-defaulted-parameter-order.md" class="">https://github.com/apple/swift-evolution/blob/master/proposals/0060-defaulted-parameter-order.md</a><br class=""><br class="">Reviews are an important part of the Swift evolution process. All reviews should be sent to the swift-evolution mailing list at<br class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">        </span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""><br class="">or, if you would like to keep your feedback private, directly to the review manager.<br class=""><br class="">What goes into a review?<br class=""><br class="">The goal of the review process is to improve the proposal under review through constructive criticism and contribute to the direction of Swift. When writing your review, here are some questions you might want to answer in your review:<br class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>* What is your evaluation of the proposal?<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>* Is the problem being addressed significant enough to warrant a change to Swift?<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>* Does this proposal fit well with the feel and direction of Swift?<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>* If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>* How much effort did you put into your review? A glance, a quick reading, or an in-depth study?<br class=""><br class="">More information about the Swift evolution process is available at<br class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">        </span><a href="https://github.com/apple/swift-evolution/blob/master/process.md" class="">https://github.com/apple/swift-evolution/blob/master/process.md</a><br class=""><br class="">Thank you,<br class=""><br class="">-Chris Lattner<br class="">Review Manager<br class=""><br class=""><br class="">_______________________________________________<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></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>