[swift-evolution] [Review] SE-0045: Add scan, prefix(while:), drop(while:), and iterate to the stdlib
Matthew Johnson
matthew at anandabits.com
Fri Apr 29 10:56:11 CDT 2016
> On Apr 29, 2016, at 9:44 AM, David Rönnqvist via swift-evolution <swift-evolution at swift.org> wrote:
>
>
>> * What is your evaluation of the proposal?
+1 in general, with some reservations about naming.
>
> +1 This is a useful addition.
>
> As other have already pointed out, I also feel that `scan` is the least intuitive name among these and that the `reduce`/`reductions` pairing would do a good job at explaining the relation between the two.
I agree that scan is not a great name and reductions is much more clear.
>
> If I’ve understood the evolution process correctly, the broader naming of existing prefix, suffix, split, dropFirst, dropLast, etc. functions is not in scope of this proposal. Given that, I feel that the main goal regarding naming the proposed functions is to fit in well with the existing name. I feel that there is a small “term of art” argument to be made for takeWhile/dropWhile, but also that prefix(while:)/drop(while:) is a closer match to Swifts naming of similar existing functions. I don’t have strong preferences for either of these naming and would be absolutely fine with either.
I think the “term of art” argument for “take” rather than “prefix” is significant. I would much prefer that name be used. It is immediately clear, while “prefix" isn’t nearly as clear IMO.
It would be fine with me if we accept this proposal as-is and have a future proposal to address the broader naming issue.
>
>> * Is the problem being addressed significant enough to warrant a change to Swift?
>
> Yes, these are good building blocks for other functionality and are useful additions to the standard library
>
>> * Does this proposal fit well with the feel and direction of Swift?
>
> Yes, in both naming and functionality it fits well with existing functions for operating on sequences and collections
>
>> * If you have you used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?
>
> I wonder if something like Haskell’s [`span`][1] (returning a tuple of `prefix(while:)` and `drop(while:)` would be a good addition alongside these. It also doesn’t have a very intuitive name, so in that case we would have to come up with something better.
>
> [1]: http://hackage.haskell.org/package/base-4.8.2.0/docs/Prelude.html#v:span
>
>> * How much effort did you put into your review? A glance, a quick reading, or an in-depth study?
>
> Read of the proposal, read the evolution proposal thread, and a small study of similar features in other languages.
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
More information about the swift-evolution
mailing list