[swift-evolution] [Idea] Omit argument labels from the call site when the argument is the same as the label

Kenny Leung kenny_leung at pobox.com
Sun Feb 7 13:45:59 CST 2016


Hi All.

I’m just throwing this out there.

often when I write Objective-C, my method calls end up looking like this:

[you doYourThingWithThis:this that:that these:these those:those other:other];

This reads poorly and requires extra typing. It would be nice if the compiler just assumed that when no label is given, the label is the same as the argument name. The code would be just as understandable (more) than if the argument labels were actually there.

In Swift, this:

you.doYourThingWithThis(this, that:that, these:these, those:those, other:other)

becomes

you.doYourThingWithThis(this, that, these, those, other)

However, if you are the type that likes to name your variables a,b,c,d, no harm done, since then labels would be required, and it would still read OK

you.doYourThingWithThis(a, that:b, these:c, those:d, other:e)

-Kenny



More information about the swift-evolution mailing list