<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Nov 7, 2017, at 3:34 PM, Kevin Ballard via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<title class=""></title>
<div class=""><div class="">On Tue, Nov 7, 2017, at 03:23 PM, John McCall via swift-evolution wrote:<br class=""></div>
<blockquote type="cite" class=""><blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:40px;border-top-width:initial;border-right-width:initial;border-bottom-width:initial;border-left-width:initial;border-top-style:none;border-right-style:none;border-bottom-style:none;border-left-style:none;border-top-color:initial;border-right-color:initial;border-bottom-color:initial;border-left-color:initial;border-image-source:initial;border-image-slice:initial;border-image-width:initial;border-image-outset:initial;border-image-repeat:initial;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;" class=""><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><br class=""></div>
</blockquote><div class=""><br class=""></div>
<div class=""><div class="">• What is your evaluation of the proposal?<br class=""></div>
</div>
</blockquote><div class=""><br class=""></div>
<div class="">This proposal is going to cause an insane amount of code churn. The proposal suggests this overload of flatMap is used "in certain circumstances", but in my experience it's more like 99% of all flatMaps on sequences are to deal with optionals, not to flatten nested sequences.<br class=""></div>
<div class=""><br class=""></div>
<blockquote type="cite" class=""><div class=""><div class="">• Is the problem being addressed significant enough to warrant a change to Swift?<br class=""></div>
</div>
</blockquote><div class=""><br class=""></div>
<div class="">I don't think so. It's a fairly minor issue, one that really only affects new Swift programmers anyway rather than all users, and it will cause far too much code churn to be worthwhile.<br class=""></div>
<div class=""><br class=""></div>
<div class="">I'd much rather see a proposal to add a new @available type, something like 'warning’,</div></div></div></blockquote><div>Please write one, seriously!</div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><div class=""> that lets you attach an arbitrary warning message to a call (which you can kind of do with 'deprecated' except that makes the warning message claim the API is deprecated). With that sort of thing we could then declare<br class=""></div>
<div class=""><br class=""></div>
<div class="">extension Sequence {<br class=""></div>
<div class=""> @available(*, warning: "Use map instead")</div>
<div class=""> func flatMap<U>(_ f: (Element) -> U) -> [U] {<br class=""></div>
<div class=""> return map(f)<br class=""></div>
<div class=""> }<br class=""></div>
<div class="">}<br class=""></div></div></div></blockquote>FWIW: This was attempted in the past, and had to be reverted for the reason other than «deprecated» being a confusing message.<br class=""><a href="https://github.com/apple/swift/pull/9390" class="">https://github.com/apple/swift/pull/9390</a></div><div><br class=""></div><div><br class=""><blockquote type="cite" class=""><div class=""><div class="">
<div class=""><br class=""></div>
<div class="">And now if someone writes flatMap in a way that invokes optional hoisting, it'll match this overload instead and warn them.</div>
<div class=""><br class=""></div>
<blockquote type="cite" class=""><div class=""><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>
</blockquote><div class=""><br class=""></div>
<div class="">A quick reading, and a couple of minutes testing overload behavior with availability attributes (to confirm that we can't simply use 'unavailable' for this).<br class=""></div>
<div class=""><br class=""></div>
<div class="">-Kevin Ballard</div>
<div class=""><br class=""></div>
</div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>