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

Alejandro Martinez alexito4 at gmail.com
Fri Nov 10 10:35:51 CST 2017


https://github.com/apple/swift-evolution/blob/master/proposals/0187-introduce-filtermap.md

+1 to change it (but the filterMap doesn't' seem perfect neither)

• What is your evaluation of the proposal?

I'm in favour of renaming that specific variant of flatMap but I'm not
100% that filterMap is the best alternative name.

• Is the problem being addressed significant enough to warrant a
change to Swift?

Yes, maybe with a migration option to make the transition nicer

When introducing functional concepts the majority of people always
struggles with flatMap, and this specific Swift variant of it makes it
even harder. At the end I endup ignoring it for explanations and
telling them "and Swift has this specific one that is nice to have but
don't mind that it's called flatMap because it is not".
Is super convenient to have, so I still want that method to exist, but
the flatMap name invoques a specific known set of rules that this
version doesn't respect.

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

Yes, having this convenience is really nice when writing code, but
making naming clear is also really important.

• If you have used other languages or libraries with a similar
feature, how do you feel that this proposal compares to those?

Not much to add here.

• How much effort did you put into your review? A glance, a quick
reading, or an in-depth study?

I wrote about this as soon as Swift was released years ago and have
been seeing the effect of this on every newcomer I've teached Swift.
But as I said, not a big fan the name suggested but I don't have
strong opinion about alternatives.


On Fri, Nov 10, 2017 at 3:37 PM, BJ Homer via swift-evolution
<swift-evolution at swift.org> wrote:
>
>
>> On Nov 10, 2017, at 5:07 AM, Tino Heth <2th at gmx.de> wrote:
>>
>> A: Well, it does a mapping, and then applies a filter to get rid of nils,
>
> I prefer to think of it this way: it does a mapping, and keeps the results where the closure did not return nil. In the example given earlier, the closure returned Optional<Int?>.some(nil), which is not “nil”.
>
> -BJ
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution



-- 
Alejandro Martinez
http://alejandromp.com


More information about the swift-evolution mailing list