<html><head><style>body{font-family:Helvetica,Arial;font-size:13px}</style></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">The typical case for this function in my code is the identity closure, that is</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">&nbsp; &nbsp; let a: [Int?] = ...</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">&nbsp; &nbsp; print(a.filterMap {$0})</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">filterMap is quite poor for this situation because *each* component in the term is inaccurate:</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">1. &nbsp;While we are filtering in the "english sense", in Swift the word "filter" carries a specific meaning involving booleans. &nbsp;In particular if `a` were of type `[Bool?]` I believe new Swift programmers would fail to predict the result</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">2. &nbsp;This is not a map operation when used with the identity closure. &nbsp;</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">Most of the discussion so far addresses 1 but not 2, e.g. mapSome, mapCompact improve dimension 1 but not dimension 2.</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">I support mapMaybe because from the choices so far it is the only one that seems to address both dimensions.</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">It can also be argued that the combined API itself is a mistake, e.g. that a distinct API for discarding optionals as from mapping would be superior. &nbsp;But that may be too radical at this point.</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><p class="airmail_on">On November 15, 2017 at 2:55:10 PM, John McCall (<a href="mailto:rjmccall@apple.com">rjmccall@apple.com</a>) wrote:</p> <blockquote type="cite" class="clean_bq"><span><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div></div><div>



<title></title>


Hello, Swift Community!
<div class=""><br class=""></div>
<div class="">The initial review of "SE-0187: Introduce
Sequence.filterMap(_:)" ran through yesterday, November 14th, 2017.
&nbsp;The proposal is available here:</div>
<div class=""><br class=""></div>
<blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;">
<div class=""><a href="https://github.com/apple/swift-evolution/blob/master/proposals/0187-introduce-filtermap.md" class="">https://github.com/apple/swift-evolution/blob/master/proposals/0187-introduce-filtermap.md</a></div>
</blockquote>
<div class=""><br class=""></div>
<div class="">There was a significant amount of discussion, and
people came down with reasonable arguments both for and against the
proposal. &nbsp;After reviewing that feedback, the core team feels
that the central question is whether Swift benefits from
overloading flatMap in this way. &nbsp;There is a reasonable
argument that an Optional is a sort of container, and therefore it
makes sense to "flatten" that container into a surrounding
container. &nbsp;But Swift has resisted applying that
interpretation in its library design; for example, you cannot
directly iterate an Optional or append its contents to an Array.
&nbsp;In general, we feel that using different operations for
working with Optionals tends to make code easier to both write and
understand, especially given the existence of implicit optional
promotion, which we cannot eliminate or easily suppress based on
the context. &nbsp;On reflection, we think it was a mistake to use
the same name in the first place, and there is no better time to
fix a mistake than now.</div>
<div class=""><br class=""></div>
<div class="">While we accept that this will cause some amount of
"code churn" for developers when they adopt Swift 5, the required
change is a simple rename that should be painless to automatically
migrate. &nbsp;Of course, sample code on the internet will become
obsolete, but fix-its will easily update that code if pasted into a
project, and the samples themselves (once corrected) should become
clearer and easier to teach after this change, as is generally true
when overloading is removed.</div>
<div class=""><br class=""></div>
<div class="">Accordingly, SE-0187 is <b class="">accepted</b>, at
least as far as not calling the operation "flatMap". &nbsp;We are
re-opening the review until next Monday, November 20th, 2017, in
order to have a focused discussion about the new name. &nbsp;Names
that seemed to gain some traction in the first review
include:</div>
<div class=""><br class=""></div>
<div class="">&nbsp; - filterMap, which has precedent in existing
functional languages, as well as some popular Swift libraries, but
which some people view as confusing</div>
<div class=""><br class=""></div>
<div class="">&nbsp; - compactMap, which builds off the precedent
of "compact" in Ruby</div>
<div class=""><br class=""></div>
<div class="">But please feel free to suggest a name other than
these.</div>
<div class=""><br class=""></div>
<div class=""><b class="">Reviews</b></div>
<div class=""><br class=""></div>
<div class="">
<div class="">Reviews are an important part of the Swift evolution
process. &nbsp;All reviews should be sent to the swift-evolution
mailing list at</div>
<div class=""><br class=""></div>
<blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></blockquote>
<br class="">
or, if you would like to keep your feedback private, directly to me
as the review manager. &nbsp;When replying, please try to keep the
proposal link at the top of the&nbsp;message:<br class="">
<br class="">
<blockquote class="" style="box-sizing: border-box; margin: 0px 0px 16px; padding: 0px 1em; border-left-width: 0.25em; border-left-style: solid; border-left-color: rgb(223, 226, 229); background-color: rgb(255, 255, 255);">
<p class="" style="color: rgb(106, 115, 125); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; box-sizing: border-box; margin-top: 0px; margin-bottom: 16px;">
Proposal link:</p>
<blockquote class="" style="box-sizing: border-box; margin: 0px; padding: 0px 1em; border-left-width: 0.25em; border-left-style: solid; border-left-color: rgb(223, 226, 229);">
<a href="https://github.com/apple/swift-evolution/blob/master/proposals/0187-introduce-filtermap.md" class=""><font size="3" class="">https://github.com/apple/swift-evolution/blob/master/proposals/0187-introduce-filtermap.md</font></a></blockquote>
</blockquote>
<blockquote class="" style="box-sizing: border-box; margin: 0px 0px 16px; padding: 0px 1em; color: rgb(106, 115, 125); border-left-width: 0.25em; border-left-style: solid; border-left-color: rgb(223, 226, 229); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">
<div class="" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 0px;">
Reply text</div>
</blockquote>
<blockquote class="" style="box-sizing: border-box; margin: 0px 0px 16px; padding: 0px 1em; color: rgb(106, 115, 125); border-left-width: 0.25em; border-left-style: solid; border-left-color: rgb(223, 226, 229); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">
<blockquote class="" style="box-sizing: border-box; margin: 0px; padding: 0px 1em; border-left-width: 0.25em; border-left-style: solid; border-left-color: rgb(223, 226, 229);">
<div class="" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 0px;">
Other replies</div>
</blockquote>
</blockquote>
<b class="">What goes into a review?</b><br class="">
<br class="">
The goal of the review process is to improve the proposal under
review through constructive criticism and, eventually, determine
the direction of Swift.
<div class=""><br class=""></div>
<div class="">When writing your review, here are some questions you
might want to answer in your review:<br class="">
<br class="">
<div class="">• What is your evaluation of the proposal?<br class=""></div>
<div class="">• Is the problem being addressed significant enough
to warrant a change to Swift?<br class=""></div>
<div class="">• Does this proposal fit well with the feel and
direction of Swift?<br class=""></div>
<div class="">• If you have used other languages or libraries with
a similar feature, how do you feel that this proposal compares to
those?<br class=""></div>
<div class="">• How much effort did you put into your review? A
glance, a quick reading, or an in-depth study?<br class=""></div>
<div class=""><br class=""></div>
More information about the Swift evolution process is available at:
<div class=""><br class=""></div>
<blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;">
<div class=""><a href="https://github.com/apple/swift-evolution/blob/master/process.md" class="">https://github.com/apple/swift-evolution/blob/master/process.md</a></div>
</blockquote>
<div class=""><br class="">
As always, thank you for contributing to the evolution of
Swift.<br class="">
<br class="">
John McCall<br class="">
Review Manager</div>
</div>
</div>


_______________________________________________<br>swift-evolution-announce mailing list<br>swift-evolution-announce@swift.org<br>https://lists.swift.org/mailman/listinfo/swift-evolution-announce<br></div></div></span></blockquote></body></html>