[swift-evolution] Proposal: Add scan, takeWhile, dropWhile, and iterate to the stdlib

Erica Sadun erica at ericasadun.com
Sun Mar 6 10:48:51 CST 2016


> On Mar 5, 2016, at 10:38 PM, Dave Abrahams via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 
> on Mon Dec 28 2015, Kevin Ballard <swift-evolution-AT-swift.org <http://swift-evolution-at-swift.org/>> wrote:
> 
>> ## Introduction
>> 
>> Add a few more functional sequence utilities to the standard library.
>> 
>> ## Motivation
>> 
>> We have map, filter, and reduce, but we're missing a bunch of useful
>> utilities like scan, iterate, takeWhile, and dropWhile. Interestingly,
>> the stdlib includes an implementation of scan in the doc comment for
>> LazySequenceType, it just doesn't actually provide it as API.
> 
> One of my concerns here is that while map, filter, and reduce are mostly
> “lingua franca” terms-of-art among programmers everywhere, these others
> are much less commonly-known and some of them aren't very descriptive of
> what they do.  There are lots more like these in the FP lexicon.  It was
> easy to draw the line at map/filter/reduce (which also don't follow the
> usual grammar for API guidelines), but if we take the ones in this
> proposal, where do we stop?

Let not to the adoption of great FP admit impediments <http://www.shakespeare-online.com/sonnets/116.html>. 
Names are not an ever-fixed mark that travels between languages 
and are never shaken. While map, filter, and reduce are 
terms of art, Swift offers new opportunities to incorporate 
other time tested FP with names better descriptive of what they do.
If names be flawed, brief hours (or weeks) bikeshedding
can be the wandering functions's guiding star
moving them towards Swift's welcoming harbor.

-- E

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160306/baf68200/attachment.html>


More information about the swift-evolution mailing list