[swift-evolution] When to use argument labels, part DEUX

Dave Abrahams dabrahams at apple.com
Sat Feb 6 23:43:00 CST 2016

on Sat Feb 06 2016, Thorsten Seitz <swift-evolution at swift.org> wrote:

> Am 06.02.2016 um 02:59 schrieb Dave Abrahams via swift-evolution <swift-evolution at swift.org>:
>>> When the natural semantic relationship between the arguments is
>>> stronger than the relationship between the method name and the first
>>> argument, use first argument labels, whether the label is a noun or a
>>> preposition:
>>> a.move(from: b, to: c)
>>> a.login(username: b, password: c)
>> You don't need this additional guideline to get
>>  a.login(username: b, password: c)
>> a login b is not part of a grammatical phrase with the right semantics,
>> therefore the first argument gets a label.  
> Could you explain why `a login b` is not sufficient? Is it because I
> cannot log in a username but only a user?

I guess I would consider it grammatical if it was a.logInAs(b), and
arguably if we say names and IDs don't need a preceding noun, then
a.logIn(b) could be sufficient in this case, but I guess it's the
lowercasing of "login" that makes me read "a.login(b)" as ungrammatical.

There are *gonna* be gray areas no matter what we do; this might be one
of them.


More information about the swift-evolution mailing list