[swift-evolution] Utilizing arguments without meaningful internal names

Jessy Catterwaul mr.jessy at gmail.com
Wed Feb 3 23:32:27 CST 2016


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
}

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.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160204/3de4a4f4/attachment.html>


More information about the swift-evolution mailing list