[swift-evolution] [Pitch] Enforce argument order for defaulted parameters
xenadu at gmail.com
Wed Mar 30 13:35:31 CDT 2016
> On Mar 30, 2016, at 9:59 AM, Joe Groff via swift-evolution <swift-evolution at swift.org> wrote:
> Many people are surprised when they find out defaulted parameters can be reordered, unlike required arguments. This special case adds complexity to the language, and runs against our general trend of treating argument labels as a significant part of an API's name, and preferring a single way of writing API calls. I think it's worth revisiting this design choice—is the special case worth the complexity? How many people take advantage of default argument reordering?
Now that we’re labelling the first argument it is only inconsistent because you can’t arbitrarily reorder the required named parameters, though that’s not something I feel strongly about.
I personally like it because I consider the defaulted parameters to be “extra add-ons” or the alternative to a “userInfo: [String: AnyObject]” pattern.
I’d vote to leave things as-is unless it imposes a significant maintenance cost on the compiler.
More information about the swift-evolution