[swift-evolution] named parameters - why hidden first?/proposal interest
dabrahams at apple.com
Sat Jan 23 05:34:16 CST 2016
on Fri Jan 22 2016, Charles Srstka <swift-evolution at swift.org> wrote:
>> On Jan 21, 2016, at 1:25 PM, Tony Parker via swift-evolution
>> <swift-evolution at swift.org> wrote:
>> We surveyed the entire surface area of the iOS and OS X SDKs,
>> looking to see how many arguments typical methods had. We found that
>> the vast majority of methods actually have just one argument. If we
>> went with a rule that first arguments should be named, then methods
>> would be this instead:
>> say(message: “hello”)
>> which isn’t really much of an improvement, in my mind.
> How about making it so that methods with just one argument have no
> label on the argument by default, but methods with two or more
> arguments have labels on all arguments? This would prevent what you
> describe above, while eliminating the ugliness of one parameter being
> treated differently from all the rest in the same method.
...and replace it with the ugliness of one parameter being treated
differently from two. It would also force me to write "_" explicitly on
the first parameter of all of my 2+ parameter methods. Yes, it's a
little bit weird, but when optimizing APIs for readability at the call
site, the defaults we have actually work in practice.
More information about the swift-evolution