I’m passing on some feedback from a contributor who preferred to remain 
anonymous / offlist and emailed the review manager.  These are not my personal 
comments:

On Apr 28, 2016, at 11:11 AM, Chris Lattner <[email protected]> wrote:
> Proposal:
>       
> https://github.com/apple/swift-evolution/blob/master/proposals/0045-scan-takewhile-dropwhile.md
> 

I would really like a different name for scan. While it’s the term of art for 
Haskell and co, it really seems meaningless to regular programmers (why is 
“scanning” the way you produce an array of intermediate reduces?), and it would 
be better to follow the pattern already established elsewhere in the library to 
give friendlier names e.g. flatMap instead of bind, reduce instead of fold.

I think Python calls it accumulate: 
http://docs.python.org/3/library/itertools.html#itertools.accumulate

While this isn’t great either, because you can think of reduce as 
“accumulating” a value, I still think it’ll be easy for people to understand 
the difference and remember which is which (since reducing sounds like boiling 
down, accumulating more like gathering multiple things and sounds similar to 
“cumulative”).

I also think it would be nice for both scan and reduce to have overloads that 
take the first value as the initial (and return an optional) but that’s 
probably a separate proposal.

Other than that, I think these will all make very useful additions to the 
library.


_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to