[swift-evolution] rename dropFirst() and dropLast()

David Waite david at alkaline-solutions.com
Mon Dec 28 19:35:44 CST 2015


If one were to rename dropFirst/dropLast, I’d love for prefix and suffix to be renamed also to better pair with the methods.

Something like:
- absorbingFirst
- discardingFirst
- disregardingFirst
- droppingFirst
- eliminatingFirst
- excludingFirst
- filteringFirst
- ignoringFirst
- refusingFirst
- removingFirst

paired with an alternate name for “prefix”:
- acceptingFirst
- choosingFirst
- harvestingFirst
- includingFirst
- outputtingFirst
- pickingFirst
- selectingFirst
- takingFirst

Alternatively (and perhaps clearer) once could take “prefix” and pair it with a prefix-dropping method:
- absorbingPrefix
- discardingPrefix
- disregardingPrefix
- droppingPrefix
- eliminatingPrefix
- excludingPrefix
- filteringPrefix
- ignoringPrefix
- refusingPrefix
- removingPrefix

My vote? “prefix” and “ignoringPrefix” paired with “suffix” and “ignoringSuffix”. Words like ‘absorb’, ‘disregard’ and ‘ignore’ seem to better indicate what the default algorithm is going to do.

(Of course with that logic, “suffix” is a terribly misleading name w.r.t. complexity and memory usage, when you consider what the generator-backed implementation has to do)

-DW

> On Dec 28, 2015, at 5:49 PM, Michel Fortin via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Le 28 déc. 2015 à 19:25, Kevin Ballard <kevin at sb.org> a écrit :
> 
>> To add to this, existing Swift and Obj-C precedent says the mutating method will be named with "remove" (e.g. `removeFirst`). So the logical name for this based on the grammar rule is `removingFirst`, but that also sounds weird to me.
> 
> Sounds fine to me, but I'll admit not being a native English speaker. I know I would never have thought looking for `drop` when looking for the non-mutating version. Seems I'm not familiar enough with Rust and Haskell. It's a certainly a nice thing that if I began by writing `remove`, autocompletion would have suggested `removing`: no guesswork with synonyms to find the non-mutating variant.
> 
> -- 
> Michel Fortin
> https://michelf.ca
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution



More information about the swift-evolution mailing list