[swift-evolution] When to use argument labels (a new approach)

Dave Abrahams dabrahams at apple.com
Fri Feb 5 13:16:51 CST 2016

on Fri Feb 05 2016, Brent Royal-Gordon <swift-evolution at swift.org> wrote:

>> Here are then the examples of good use cases:
>> No First Argument Labels
>> a.readFrom(u, ofType: b)          // yes, satisfies rules 1 and 2
>> a.readFrom(source: u, ofType: b)  // no, source is explicitly derived by “From”
>> Keep First Argument Labels Labels
>> a.read(u, ofType: b)          // no, it’s not clear what u’s role is
>> a.read(source: u, ofType: b)  // yes, the source being read is not clear, it could be stdin,
> Okay, but which should it be? `readFrom(_:...)` or `read(source:...)`?
> These two APIs have very different flavors, and you seem to be saying
> that either one is okay. That's not a very good thing if we're trying
> to define what "Swifty" APIs look like.

One good way to make this determination, if the answer isn't obvious:
“which choice makes for simpler guidelines?”


More information about the swift-evolution mailing list