[swift-evolution] [Draft] Rationalizing Sequence end-operation names

Brent Royal-Gordon brent at architechies.com
Mon Jun 27 21:23:08 CDT 2016


> Just want to point out that `prefix` and `suffix` may introduce ambiguity, as they are also imperative verbs. For example, `S.prefix(1)` can be inferred as prefixing `1` to the sequence, instead of retrieving the prefix of the sequence.

While that is true, I think the types will usually explain what's going on—`prefix` takes an `Int` (not an `Element`) and returns a `SubSequence` (not `Void`), and is also `nonmutating`. That seems like enough contextual hints to tell you what's going on.

> IMO `skip`, as an alternative listed in the proposal, would convey the intention better and clearer, and it has roots in the sequence-like constructs of reactive programming libraries (e.g. RxSwift and ReactiveCocoa).

That's an interesting and very, very relevant precedent. Thanks for mentioning it!

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list