Bad naming in Standard Library

I just made the exact same mistake (again) as described in this 4 year old thread:

Why hasn't dropFirst() and dropLast() been renamed (to eg droppingFirst() and droppingLast())?

I mean, according to the API naming guidelines and the resulting "feel" of the language, .dropLast() would be a mutating method that removes the last element, ie something very similar to the existing methods .removeLast() and popLast().


Are there other similarly bad names in the Standard Library?

20 Likes

All the term of art like map, filter, etc.

2 Likes

I'm very +1 on fixing that, I assume that it is just the case that no one has proposed it. It should be straight forward to introduce the proper names and deprecate the old ones.

-Chris

21 Likes

I don't have the time to write formal proposals, and I'm not sure what the proper names would be, some examples I can think of right now:

withoutFirst()
droppingFirst()
skippingFirst()
removingFirst()

(And the same for …Last())

I proposed it at the end of the Swift 3 cycle, but it got returned for revision, there wasn’t enough time to run it again, and then we declared source compatibility. The proposal is still in the repo—I think it was somewhere around 130, but I could be wrong. If we’re okay with the source compatibility impact, we could dust it off and modify it to deprecate the old names without removing them.

Edit: Now that I'm not on my phone, I've looked it up: SE-0132 Rationalizing Sequence end-operation names

10 Likes