[swift-evolution] When to use argument labels (a new approach)
dabrahams at apple.com
Thu Feb 4 13:52:38 CST 2016
on Thu Feb 04 2016, Charles Constant <swift-evolution at swift.org> wrote:
>> Why isn't "to" more predictable than "toPoint?" It's certainly more
> Function arguments can be unordered, if they have default values. A
> contrived example here...
> func rename( from nameA="index", from extA="html", to nameB="converted", to
> extB="shtml" )
> Maybe I'm confused, but that seems like it has to be illegal at worst, and
> confusing at best. But if you don't consistently use "from" and "to" then
> you're back to making special rules about everything.
I think it's a confusing and probably bad API no matter how you choose
file.rename(from: ("index", "html"), to: ("converted", "shtml"))
> It wouldn't matter if every argument has a unique Type, or if you take the
> time to create structs or tuples to bundle every piece of data together
> about "from" or about "with" etc. Maybe that's usually the case, but it's
> nice to have freedom to be lazy.
Let me be clear: these API guidelines are *not* going to optimize for
churning out APIs without careful consideration; it's thoroughly
incompatible with their mission. If you want that freedom, you're free
to ignore the guidelines. Sorry to be blunt, but that's how it is.
More information about the swift-evolution