On Fri, May 6, 2016, at 05:19 PM, Dave Abrahams via swift-evolution wrote:
>
> on Wed May 04 2016, Chris Lattner <[email protected]> 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})
Using "where:" has a very high potential for confusion, because "where" makes
it sound like it runs the predicate against every single element, whereas
"while" makes it clear that it stops evaluating elements once the predicate
returns false. Or in other words, `drop(where: predicate)` looks like it should
be equivalent to `filter({ !predicate($0) })`.
-Kevin Ballard
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution