[swift-evolution] Utilizing arguments without meaningful internal names
Dave Abrahams
dabrahams at apple.com
Thu Feb 4 02:26:42 CST 2016
on Wed Feb 03 2016, Jessy Catterwaul <swift-evolution at swift.org> wrote:
> I’ve found that good external parameter names are typically just prepositions.
>
> Sometimes the noun that comes after the prepositions doesn’t benefit
> from a real name. I’ve been naming those _$0 to minimize cognitive
> load. (I don’t think about the name when writing, and when reading, I
> know that the name would be useless to commit to my short-term
> memory.)
>
> func move<Point>(to _$0: Point) {
> // argument is accessible as _$0
> }
Try to write a documentation comment summary for this without mentioning
_$0. The parameter names actually matter.
> Currently, this also compiles:
>
> func move<Point>(to _: Point) {
> // argument is inaccessible
> }
>
> Is that useless? I think it’s useless but I might be missing something.
>
> I propose that, when external parameter names are used, but internal
> ones use underscores, the arguments are accessible as $0, $1, etc. (I
> use $0 a lot, and $1 a little, but have not yet needed $2,
> personally.)
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
--
-Dave
More information about the swift-evolution
mailing list