There’s a pretty interesting proposal discussion on swift-evolution right now: Naming Functions with Argument Labels.
I bring it up because it hits a bit close to my heart with regards to naming of functions named arguments. It’s my opinion that Swift should have diverged from ObjC here and treated named arguments properly. What I mean by that is to move the argument name within the function parameters completely.
So a function name like this:
func insertSubview(view, aboveSubview) {}
Would have become:
func insert(subview, aboveSubview)
The difference is the lack of the implicit _
on the first argument name. I bring this up (again) because of the given proposal shows well why I think the current convention stinks.
let fn = someView.insertSubview(_:aboveSubview:)
Ick! Why is that _
necessary. Oh‚Ķ right, because we’ve shoved the actual parameter name for that first item into the name of the function. ObjC did this for a compelling reason. Swift seems to simply follow that convention for what I can only presume to be convenience in the Swift to ObjC interop.
Too bad, this seems so much nicer to me:
let fn = someView.insert(subview:aboveView:)
Maybe someday…