I advocated for embracing subrange in this revision of the proposal in large part because of your observation that "subrange" is the existing term of art for "a range of positions in a collection":
A subrange is not "a range of elements in a collection":
- Swift already has
SubSequenceandSlicefor that. - If it were,
removeSubrangewouldn't be any clearer thanremoveRange.
I think of "subrange" now as "a range of positions that represent consecutive elements in a collection". So numbers.subranges { $0.isMultiple(of: 2) } is returning "the positions of the elements that are a multiple of 2".
I think there's a lot of nice synergy with removeSubrange(_:) and replaceSubrange(_:with:) in naming the algorithms subranges(where:), removeSubranges(_:), and moveSubranges(_:to:). (Also I imagine we'll be adding moveSubrange(_:to:) soon, in a follow up proposal.)