On Nov 9, 2017, at 9:13 AM, Tino Heth via swift-evolution
<swift-evolution@swift.org> wrote:
>
>
>> Experienced programmers (as experienced as any Swift programmer can be for a
>> 4-year-old language) frequently use flatMap when they mean map
> When you look at those examples:
> What would stop those programmers to use filterMap in the exact same way,
> instead of switching to map?
> A hypothetic migrator most likely would just replace names…
The migrator would already have to be aware of the return type of the closure
(to avoid migrating cases where it’s actually returning a sequence as
expected), so the migrator could easily only migrate the ones that are actually
returning optionals in the first place.
Programmers could continue to use filterMap incorrectly, but it would be a more
explicit choice. Currently, there’s a sense among some Swift users (including
some that I know personally) that flatMap is the “smart” thing to use with
collections because monads or something, without any real understanding of why
that is. (Remember, Swift doesn’t even have a “flatten()” function anymore, so
the name “flatMap" is far from obvious.) I think it’s less likely that people
will continue to use “filterMap” when they know no filtering is happening.
-BJ
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution