[swift-evolution] [Proposal] Shorthand Argument Renaming
Erica Sadun
erica at ericasadun.com
Mon May 30 16:17:14 CDT 2016
> On May 30, 2016, at 2:19 PM, Frédéric Blondiau via swift-evolution <swift-evolution at swift.org> wrote:
>
> I personally never found that this “$n” convention was “Swift-like”... but it’s true that a “$n” is easier to spot than a “.n”, and I got used to also.
>
> However, I realised how much this was disturbing for newcomers, when explaining closure shorthand argument names to a classroom of computer science students (aged 21) discovering Swift.
>
> The feedback some gave me, during the course, was quite surprisingly strong and negative about this “$n” convention. This convinced me to write this proposal : for newcomers, the “$n” zero-based is something wrong.
>
> I understand that association between tuples and function parameters in Swift is to be removed, but, in this case, as we have no parameters at all, I thought this was a distinct enough situation.
>
> As suggested, considering this is a kind of compiler magic, using #0, #1 instead, may indeed be a better alternative.
>
> I’m still waiting some feedback before writing an official proposal.
I really don't see a pressing need to change this. Zero-based counting is used in Swift arrays. I don't think the $-prefix is either superior or inferior to alternatives such as # or %, and has precedent in unix shell programming. Swift closures allow you to easily introduce meaningful names by using a closure signature with a parameter clause.
-- E
More information about the swift-evolution
mailing list