|
|
|
|
|
by mikeash
3822 days ago
|
|
Can you explain what "and require using when just wanting positional-only parameters, or consistently labelled parameters" means? I don't understand that. As for why you have it in the first place, it's just because one is API and one is implementation, and there are sometimes good reasons to have them be different. |
|
As far as I can see (and the article notes), by default the first parameter of a Swift function is unlabelled, and the others are labelled. That is at callsite the first parameter can not be labelled and the others must be. Having either all-positional or all-labelled (but still positional) requires specifying external names.
> As for why you have it in the first place, it's just because one is API and one is implementation
But again and as you yourself noted that could trivially be done with local bindings inside the function in cases where it's desirable.