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

Brent Royal-Gordon brent at architechies.com
Fri Feb 5 02:37:42 CST 2016


> 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.

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list