• What is your evaluation of the proposal?
I approve. This variant of ‘Sequence.flatMap’ is confusing to newcomers, and is 
inconsistent with the standard term-of-art usage of “flatMap”. People can learn 
what it means, but it continues to feel awkward. There will be some code churn, 
but it’s easily automatable and improves the clarity of the code. If we leave 
the existing spelling in place as deprecated, then we even preserve source 
compatibility.

• Is the problem being addressed significant enough to warrant a change to 
Swift?
I think so. The existing spelling of this functionality has three problems:
Discoverability: Users looking to filter out ‘nil’ values have to know to look 
for something that doesn’t say “filter”
Unexpected behavior: Users who are unfamiliar with the concept of Optionals as 
a Sequence-of-one have difficulty understanding why this is called “flatMap”. 
They don’t know what it does. I’ve seen this many times.
Brittleness: The functionality changes dramatically if the body of the function 
changes from returning an Optional to a Sequence. An example of this was given 
in the proposal, but here’s another one: 
struct Thing {
    var name: String? // What if this becomes non-optional in the future?
}

// If Thing.name is optional, this returns an array of names (with nil filtered 
out)
// If Thing.name becomes non-optional, this now returns an array of all the 
characters in all the names, concatenated
things.flatMap { $0.name }

In general, changing from optional to non-optional causes compiler warnings in 
cases where something wasn’t expecting that. This isn’t likely a common 
problem, but it isn’t a great argument in defense of the current situation.


• Does this proposal fit well with the feel and direction of Swift?
Yes. Clear names are a common theme in Swift, and we have other proposals in 
Swift 5 with a similar goal.

• If you have used other languages or libraries with a similar feature, how do 
you feel that this proposal compares to those?
It makes us behavior more like those other languages, reducing user surprise.

• How much effort did you put into your review? A glance, a quick reading, or 
an in-depth study?
I was in the process of writing up a similar proposal myself when this one came 
out. I’ve thought about this quite a bit, and I think it’s the right choice.


-BJ


> On Nov 7, 2017, at 4:23 PM, John McCall via swift-evolution 
> <[email protected]> wrote:
> 
> Hello, Swift community!
> 
> The review of "SE-0187: Introduce Sequence.filterMap(_:)" begins now and runs 
> through November 14th, 2017.  The proposal is available here:
> 
> 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>
> 
> Reviews are an important part of the Swift evolution process.  All reviews 
> should be sent to the swift-evolution mailing list at
> 
> https://lists.swift.org/mailman/listinfo/swift-evolution 
> <https://lists.swift.org/mailman/listinfo/swift-evolution>
> or, if you would like to keep your feedback private, directly to me as the 
> review manager.  When replying, please try to keep the proposal link at the 
> top of the message:
> 
> Proposal link:
> 
> 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>
> Reply text
> Other replies
> What goes into a review?
> 
> The goal of the review process is to improve the proposal under review 
> through constructive criticism and, eventually, determine the direction of 
> Swift.
> 
> When writing your review, here are some questions you might want to answer in 
> your review:
> 
>       • What is your evaluation of the proposal?
>       • Is the problem being addressed significant enough to warrant a change 
> to Swift?
>       • Does this proposal fit well with the feel and direction of Swift?
>       • 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?
> 
> More information about the Swift evolution process is available at:
> 
> https://github.com/apple/swift-evolution/blob/master/process.md 
> <https://github.com/apple/swift-evolution/blob/master/process.md>
> 
> As always, thank you for contributing to the evolution of Swift.
> 
> John McCall
> Review Manager
> _______________________________________________
> swift-evolution mailing list
> [email protected]
> https://lists.swift.org/mailman/listinfo/swift-evolution

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

Reply via email to