[swift-evolution] [Review] SE-0187: Introduce Sequence.filterMap(_:)

David Waite david at alkaline-solutions.com
Wed Nov 8 15:43:46 CST 2017


> On Nov 7, 2017, at 4:23 PM, John McCall via swift-evolution <swift-evolution at swift.org> wrote:
> 
> https://github.com/apple/swift-evolution/blob/master/proposals/0187-introduce-filtermap.md <https://github.com/apple/swift-evolution/blob/master/proposals/0187-introduce-filtermap.md>
> 
> 	• What is your evaluation of the proposal?

-0. I think it would be more useful first to have an attribute that either warns or prevents optional promotion, so that misuse becomes a warning or error. If it remains a problem for readability, we can consider a rename.

However, I don’t like filterMap as a name, because unlike flatMap which is a combination of two things, filterMap is a combination of three - map, filter, and a hard-coded filter that rejects nil.

This seems just as likely to create odd misuse for people who know they want to map and filter, but who would be better served and have arguably cleaner code by having a lazy sequence rather than using mapFilter, e.g. (ignoring gender data often being an anti-pattern) a conversion from an array people to an array femaleFirstNames.

> 	• Is the problem being addressed significant enough to warrant a change to Swift?
I think so, I’m just conflicted on whether this is the right solution.

> 	• Does this proposal fit well with the feel and direction of Swift?
Yes

> 	• If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?
> 	• How much effort did you put into your review? A glance, a quick reading, or an in-depth study?

In-depth study

-DW

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


More information about the swift-evolution mailing list