[swift-evolution] [Guidelines, First Argument Labels]: Prepositions inside the parens
crk at akkyra.com
Thu Feb 11 16:18:35 CST 2016
> On Feb 11, 2016, at 1:51 PM, Brent Royal-Gordon <brent at architechies.com> wrote:
>>> Between these two (sorry to repeat the same example again):
>>> func trackWith(trackID trackID: CMPersistentTrackID) -> AVAssetTrack?
>>> func track(withTrackID trackID: CMPersistentTrackID) -> AVAssetTrack?
>> I think this one particular function is possibly the worst case in the entire API. Neither “track” nor “trackWith” is a particularly good function name. But as I mentioned in a previous post, I think, for many of the Foundation functions, moving the prepositional phrase into the argument label actual aids clarity slightly. I was surprised that I ended up liking it, but I do.
> Looking at the fourth function in the diff and saying "I think this is probably the worst API in the frameworks" is a bit like looking at Jupiter and saying "I think this is probably the biggest planet in the universe". With such a small sample out of such a large set, it's far more likely that APIs with the defects seen here are *common*.
I did in fact scan through large portions of the the Foundation universe before coming to that conclusion. :-) One problem with both “track” and “trackWith” is that track can be either a noun or a verb in either case. We’ve been using this function as an exemplar right from the start, but it probably isn’t a great one.
Those who feel there are a lot of problematic function names after the latest guideline changes should certainly collate a list.
> Brent Royal-Gordon
More information about the swift-evolution