[swift-evolution] [Review] SE-0045: Add scan, prefix(while:), drop(while:), and iterate to the stdlib

David Rönnqvist david.ronnqvist at gmail.com
Fri Apr 29 09:44:34 CDT 2016

> 	* What is your evaluation of the proposal?

+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.

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.

> 	* 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- 

> 	* 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.

More information about the swift-evolution mailing list