[swift-evolution] named parameters

Jordan Rose jordan_rose at apple.com
Fri Jan 22 17:10:32 CST 2016

> On Jan 22, 2016, at 14:59, Tino Heth <2th at gmx.de> wrote:
>> If the library author decides to change the internal name, it's now a source-breaking change for clients. (Alternately, all the existing internal names are now external names, without any thought given to them, which would be just as bad.)
> Imho this is no good argument — you can extend it to ban all labels.

No, that's not the case. External names are part of the method name and signature and are part of the source and binary interface for a library. Internal names are local variables with a little bit of documentation. Every parameter has both internal and external names; it's just that the logic for what happens when you only specify one that's different.

>>> Additionally, there is a hidden(?) feature in Swift that's imho quite cool:
>>> The ability to call a function with a tuple containing the arguments
>>> let args = (4.0, exponent: 4.0)
>>> printPowWithBase(args)
>>> In this case, you end up with a first parameter without any indication of its role.
>> This feature is likely to get redesigned soon. (It has other problems.)
> Can you elaborate? I did not encounter many usecases yet, but I think it could be handy to configure a bunch of similar objects — and if it would be possible to capture the parameter tuple inside the called function, this could be forwarded to a function with the same signature easily… (especially, but not only the implementation of super)

In some contexts it's hard to distinguish between "the first parameter" and "the tuple of all parameters", and we have some weird inconsistencies where "foo(x)" and "foo((x))" do the same thing sometimes and different things other times.

There's more complexity here but I don't have it paged in; it's not so relevant to this discussion


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160122/e391bc40/attachment.html>

More information about the swift-evolution mailing list