[swift-evolution] Proposal: Add scan, takeWhile, dropWhile, and iterate to the stdlib

Dave Abrahams dabrahams at apple.com
Wed Jan 20 11:13:45 CST 2016


on Wed Jan 13 2016, Kevin Ballard via swift-evolution <swift-evolution-m3FHrko0VLzYtjvyW6yDsg-AT-public.gmane.org> wrote:

> "suffixAfter" sounds like the equivalent of dropFirst(_:), i.e. it
> sounds like it should take a count of elements to skip. Similarly,
> actually trying an expression that takes a predicate looks weird:
>
> seq.suffixAfter({ isspace($0) })
>
> Even knowing what it's supposed to do, it's hard for me to read that
> expression in any sensible fashion.
>
> Also, I'm not sure the "noun phrase" convention really makes sense for
> SequenceType methods. They're not technically mutating methods, but single-
> pass collections are in fact destructively mutated by Array-returning
> sequence methods (and the methods that return SubSequence also
> destructively mutate upon any access to the returned subsequence). Which
> is to say, despite not being marked as "mutating", they do in fact
> behave like mutating methods for single-pass sequences. Which suggests
> that verb phrases are perfectly fine.

The main problem with that reasoning is that every Collection is a
Sequence, and the vast majority of Sequences are in fact Collections (or
at least multi-pass).  So you end up with lots of verb phrases for
things that in reality are non-mutating.



More information about the swift-evolution mailing list