[swift-evolution] [Accepted with modifications] SE-0045: Add scan, prefix(while:), drop(while:), and unfold to the stdlib

Dave Abrahams dabrahams at apple.com
Fri May 6 19:19:41 CDT 2016


on Wed May 04 2016, Chris Lattner <swift-evolution at swift.org> wrote:

> Proposal link: https://github.com/apple/swift-evolution/blob/master/proposals/0045-scan-takewhile-dropwhile.md
>
> Hello Swift Community,
>
> The review of SE-0045: "Add scan, prefix(while:), drop(while:), and
> unfold to the stdlib" ran from April 28...May 3, 2016. A subset of the
> proposal is *accepted, with modifications* for Swift 3.  This proposal
> included four new additions to the standard library:
>
> Sequence.prefix(while:) & Sequence.drop(while:) - These are *accepted* as specified in revision 3 of the proposal.

I know the review is over and all, but…

Chris brought to my attention an idea that I liked, and asked me to post
here about it.  Specifically, the argument label “where:” would probably
be better than “while:”.  “While” makes it sound to me like it's going
to take a nullary predicate and be much more active.  But it's hard to
love

     s.drop(where: { $0 > 1 })
     s.drop { $0 > 1 }

because it makes it sound like a general filtering operation.

Therefore, I'd much rather see

       s.droppingPrefix(where: {$0 > 1})

-- 
Dave



More information about the swift-evolution mailing list