<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><blockquote type="cite"><p class="" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px;"><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">review of SE-0174 "Change `filter` to return an associated type" </span></font></p><ul class="" style="box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px;"><li class="" style="box-sizing: border-box;"><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">What is your evaluation of the proposal?</span></font></li></ul></blockquote>I think a change in this 'area' is valuable because currently always returning an array from collection operations is limiting. However I think this proposal feels like 'papering' over problems rather than fixing the root cause. I think it would be better to reject this and do two more adventurous proposals instead:</div><div><br></div><div> 1. Allow protocols to be generic, instead of associated types, so that you can write Sequence<T></div><div> 2. Allow Self to accept a generic argument, so that you can write Self<T></div><div><br></div><div>With these to, admittedly much more major changes, you can then write:</div><div><span class="pl-k" style="background-color: rgba(255, 255, 255, 0); box-sizing: border-box;"><br></span></div><div><span class="pl-k" style="background-color: rgba(255, 255, 255, 0); box-sizing: border-box;"> protocol Sequence<T> {</span></div><div><span class="pl-k" style="background-color: rgba(255, 255, 255, 0); box-sizing: border-box;"> func </span><span style="background-color: rgba(255, 255, 255, 0);"><span class="pl-en" style="box-sizing: border-box;">filter</span>(<span class="pl-en" style="box-sizing: border-box;">_</span> <span class="pl-smi" style="box-sizing: border-box;">isIncluded</span>: (T) <span class="pl-k" style="box-sizing: border-box;">throws</span> <span class="pl-k" style="box-sizing: border-box;">-></span> <span class="pl-c1" style="box-sizing: border-box;">Bool</span>) <span class="pl-k" style="box-sizing: border-box;">rethrows</span> <span class="pl-k" style="box-sizing: border-box;">-></span> <span class="pl-c1" style="box-sizing: border-box;">Sequence<T></span></span></div><div><span style="background-color: rgba(255, 255, 255, 0);"><span class="pl-c1" style="box-sizing: border-box;"> </span><span class="pl-k" style="box-sizing: border-box;">func map<M></span>(<span class="pl-en" style="box-sizing: border-box;">_</span> mapper: (T) <span class="pl-k" style="box-sizing: border-box;">throws</span> <span class="pl-k" style="box-sizing: border-box;">-></span> M) <span class="pl-k" style="box-sizing: border-box;">rethrows</span> <span class="pl-k" style="box-sizing: border-box;">-></span> <span class="pl-c1" style="box-sizing: border-box;">Sequence<M></span></span></div><div><span class="pl-k" style="background-color: rgba(255, 255, 255, 0); box-sizing: border-box;"> }</span></div><div><span class="pl-k" style="background-color: rgba(255, 255, 255, 0); box-sizing: border-box;"> extension</span><span style="background-color: rgba(255, 255, 255, 0);"> </span><span class="pl-en" style="background-color: rgba(255, 255, 255, 0); box-sizing: border-box;"><span class="pl-c1" style="box-sizing: border-box;">RangeReplaceableCollection</span></span><span style="background-color: rgba(255, 255, 255, 0);"> {</span></div><div><span class="pl-k" style="background-color: rgba(255, 255, 255, 0); box-sizing: border-box;"> func</span><span style="background-color: rgba(255, 255, 255, 0);"> </span><span class="pl-en" style="background-color: rgba(255, 255, 255, 0); box-sizing: border-box;">filter</span><span style="background-color: rgba(255, 255, 255, 0);">(</span><span class="pl-en" style="background-color: rgba(255, 255, 255, 0); box-sizing: border-box;">_</span><span style="background-color: rgba(255, 255, 255, 0);"> </span><span class="pl-smi" style="background-color: rgba(255, 255, 255, 0); box-sizing: border-box;">isIncluded</span><span style="background-color: rgba(255, 255, 255, 0);">: (T</span><span style="background-color: rgba(255, 255, 255, 0);">) </span><span class="pl-k" style="background-color: rgba(255, 255, 255, 0); box-sizing: border-box;">throws</span><span style="background-color: rgba(255, 255, 255, 0);"> </span><span class="pl-k" style="background-color: rgba(255, 255, 255, 0); box-sizing: border-box;">-></span><span style="background-color: rgba(255, 255, 255, 0);"> </span><span class="pl-c1" style="background-color: rgba(255, 255, 255, 0); box-sizing: border-box;">Bool</span><span style="background-color: rgba(255, 255, 255, 0);">) </span><span class="pl-k" style="background-color: rgba(255, 255, 255, 0); box-sizing: border-box;">rethrows</span><span style="background-color: rgba(255, 255, 255, 0);"> </span><span class="pl-k" style="background-color: rgba(255, 255, 255, 0); box-sizing: border-box;">-></span><span style="background-color: rgba(255, 255, 255, 0);"> </span><span class="pl-c1" style="background-color: rgba(255, 255, 255, 0); box-sizing: border-box;">Self<T></span><span style="background-color: rgba(255, 255, 255, 0);"> { </span></div><div><span style="background-color: rgba(255, 255, 255, 0);"></span><span class="pl-k" style="background-color: rgba(255, 255, 255, 0); box-sizing: border-box;"> var</span><span style="background-color: rgba(255, 255, 255, 0);"> result </span><span class="pl-k" style="background-color: rgba(255, 255, 255, 0); box-sizing: border-box;">=</span><span style="background-color: rgba(255, 255, 255, 0);"> </span><span class="pl-c1" style="background-color: rgba(255, 255, 255, 0); box-sizing: border-box;">Self<T></span><span style="background-color: rgba(255, 255, 255, 0);">() </span></div><div><span style="background-color: rgba(255, 255, 255, 0);"></span><span class="pl-k" style="background-color: rgba(255, 255, 255, 0); box-sizing: border-box;"> for</span><span style="background-color: rgba(255, 255, 255, 0);"> element </span><span class="pl-k" style="background-color: rgba(255, 255, 255, 0); box-sizing: border-box;">in</span><span style="background-color: rgba(255, 255, 255, 0);"> </span><span class="pl-c1" style="background-color: rgba(255, 255, 255, 0); box-sizing: border-box;">self</span><span style="background-color: rgba(255, 255, 255, 0);"> { </span></div><div><span style="background-color: rgba(255, 255, 255, 0);"></span><span class="pl-k" style="background-color: rgba(255, 255, 255, 0); box-sizing: border-box;"> if</span><span style="background-color: rgba(255, 255, 255, 0);"> </span><span class="pl-k" style="background-color: rgba(255, 255, 255, 0); box-sizing: border-box;">try</span><span style="background-color: rgba(255, 255, 255, 0);"> </span><span class="pl-c1" style="background-color: rgba(255, 255, 255, 0); box-sizing: border-box;">isIncluded</span><span style="background-color: rgba(255, 255, 255, 0);">(element) { </span></div><div><span style="background-color: rgba(255, 255, 255, 0);"> result.</span><span class="pl-c1" style="background-color: rgba(255, 255, 255, 0); box-sizing: border-box;">append</span><span style="background-color: rgba(255, 255, 255, 0);">(element) </span></div><div><span style="background-color: rgba(255, 255, 255, 0);"> }</span></div><div><span style="background-color: rgba(255, 255, 255, 0);"> } </span></div><div><span style="background-color: rgba(255, 255, 255, 0);"></span><span class="pl-k" style="background-color: rgba(255, 255, 255, 0); box-sizing: border-box;"> return</span><span style="background-color: rgba(255, 255, 255, 0);"> result </span></div><div><span style="background-color: rgba(255, 255, 255, 0);"> } </span></div><div><div><span style="background-color: rgba(255, 255, 255, 0);"><span class="pl-k" style="box-sizing: border-box;"> </span><span class="pl-k" style="box-sizing: border-box;">func map<M></span>(<span class="pl-en" style="box-sizing: border-box;">_</span> mapper: (T) <span class="pl-k" style="box-sizing: border-box;">throws</span> <span class="pl-k" style="box-sizing: border-box;">-></span> M) <span class="pl-k" style="box-sizing: border-box;">rethrows</span> <span class="pl-k" style="box-sizing: border-box;">-></span> <span class="pl-c1" style="box-sizing: border-box;">Self<M></span> { </span></div><div><span style="background-color: rgba(255, 255, 255, 0);"><span class="pl-k" style="box-sizing: border-box;"> var</span> result <span class="pl-k" style="box-sizing: border-box;">=</span> <span class="pl-c1" style="box-sizing: border-box;">Self<M></span>() </span></div><div><span style="background-color: rgba(255, 255, 255, 0);"><span class="pl-k" style="box-sizing: border-box;"> for</span> element <span class="pl-k" style="box-sizing: border-box;">in</span> <span class="pl-c1" style="box-sizing: border-box;">self</span> { </span></div><div><span style="background-color: rgba(255, 255, 255, 0);"> try result.<span class="pl-c1" style="box-sizing: border-box;">append</span>(mapper(element))</span></div><div><span style="background-color: rgba(255, 255, 255, 0);"> } </span></div><div><span style="background-color: rgba(255, 255, 255, 0);"><span class="pl-k" style="box-sizing: border-box;"> return</span> result </span></div><div><span style="background-color: rgba(255, 255, 255, 0);"> } </span></div></div><div><span style="background-color: rgba(255, 255, 255, 0);"> }</span></div><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="background-color: rgba(255, 255, 255, 0);">Which I think both reads better and is more powerful since it allows map to be written also.</span></div><div><br><blockquote type="cite"><ul class="" style="box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px;"><li class="" style="box-sizing: border-box; margin-top: 0.25em;"><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">Is the problem being addressed significant enough to warrant a change to Swift?</span></font></li></ul></blockquote><div>Yes, return an array is a real pain</div><br><blockquote type="cite"><ul class="" style="box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px;"><li class="" style="box-sizing: border-box; margin-top: 0.25em;"><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">Does this proposal fit well with the feel and direction of Swift?</span></font></li></ul></blockquote><div>Yes and no, really smacks of papering over other flaws. Might box Swift into a corner were other problems can't be fixed because the underlying, real, problems still remain.</div><br><blockquote type="cite"><ul class="" style="box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px;"><li class="" style="box-sizing: border-box; margin-top: 0.25em;"><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?</span></font></li></ul></blockquote><div>Virtually all other languages I have used, e.g. Java, Scala, use the solution I presented above. </div><br><blockquote type="cite"><ul class="" style="box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px;"><li class="" style="box-sizing: border-box; margin-top: 0.25em;"><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">How much effort did you put into your review? A glance, a quick reading, or an in-depth study?</span></font></li></ul></blockquote>Have been bitten by this and have written my own collection hierarchy to overcome this limitation, and others, of the current library. <br><br><div>-- Howard.</div></div><div><br>On 29 Apr 2017, at 10:06 am, Douglas Gregor <<a href="mailto:dgregor@apple.com">dgregor@apple.com</a>> wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=us-ascii"><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); 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);" class="">Hello Swift community,</p><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); 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);" class="">The review of SE-0174 "Change `filter` to return an associated type" begins now and runs through May 3, 2017. The proposal is available here:</p><blockquote 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);" class=""><div style="box-sizing: border-box; margin-top: 0px; margin-bottom: 0px;" class=""><font color="#6a737d" face="-apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol" size="3" class=""><a href="https://github.com/apple/swift-evolution/blob/master/proposals/0174-filter-range-replaceable.md" class="">https://github.com/apple/swift-evolution/blob/master/proposals/0174-filter-range-replaceable.md</a></font></div></blockquote><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); 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);" class="">Reviews are an important part of the Swift evolution process. All reviews should be sent to the swift-evolution mailing list at</p><blockquote 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);" class=""><div style="box-sizing: border-box; margin-top: 0px; margin-bottom: 0px;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="box-sizing: border-box; background-color: transparent; -webkit-text-decoration-skip: objects; color: rgb(3, 102, 214); text-decoration: none;" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); 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);" class="">or, if you would like to keep your feedback private, directly to the review manager. When replying, please try to keep the proposal link at the top of the message:</p><blockquote 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);" class=""><p 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;" class="">Proposal link:</p><blockquote 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);" class=""><div style="box-sizing: border-box; margin-top: 0px; margin-bottom: 0px;" class=""><font color="#6a737d" face="-apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol" size="3" class=""><a href="https://github.com/apple/swift-evolution/blob/master/proposals/0174-filter-range-replaceable.md" class="">https://github.com/apple/swift-evolution/blob/master/proposals/0174-filter-range-replaceable.md</a></font></div></blockquote></blockquote><blockquote 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);" class=""><div style="box-sizing: border-box; margin-top: 0px; margin-bottom: 0px;" class="">Reply text</div></blockquote><blockquote 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);" class=""><blockquote 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);" class=""><div style="box-sizing: border-box; margin-top: 0px; margin-bottom: 0px;" class="">Other replies</div></blockquote></blockquote><h5 style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 0.875em; line-height: 1.25; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);" class=""><a id="user-content-what-goes-into-a-review-1" class="anchor" href="https://github.com/apple/swift-evolution#what-goes-into-a-review-1" aria-hidden="true" style="box-sizing: border-box; background-color: transparent; -webkit-text-decoration-skip: objects; color: rgb(3, 102, 214); text-decoration: none; float: left; padding-right: 4px; margin-left: -20px; line-height: 1;"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>What goes into a review?</h5><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); 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);" class="">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:</p><ul style="box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); 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);" class=""><li style="box-sizing: border-box;" class="">What is your evaluation of the proposal?</li><li style="box-sizing: border-box; margin-top: 0.25em;" class="">Is the problem being addressed significant enough to warrant a change to Swift?</li><li style="box-sizing: border-box; margin-top: 0.25em;" class="">Does this proposal fit well with the feel and direction of Swift?</li><li style="box-sizing: border-box; margin-top: 0.25em;" class="">If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?</li><li style="box-sizing: border-box; margin-top: 0.25em;" class="">How much effort did you put into your review? A glance, a quick reading, or an in-depth study?</li></ul><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); 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);" class="">More information about the Swift evolution process is available at</p><blockquote 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);" class=""><div style="box-sizing: border-box; margin-top: 0px; margin-bottom: 0px;" class=""><a href="https://github.com/apple/swift-evolution/blob/master/process.md" style="box-sizing: border-box; background-color: transparent; -webkit-text-decoration-skip: objects; color: rgb(3, 102, 214); text-decoration: none;" class="">https://github.com/apple/swift-evolution/blob/master/process.md</a></div></blockquote><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); 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);" class="">Thank you,</p><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); 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);" class="">-Doug Gregor</p><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); 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);" class="">Review Manager</p></div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution-announce mailing list</span><br><span><a href="mailto:swift-evolution-announce@swift.org">swift-evolution-announce@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution-announce">https://lists.swift.org/mailman/listinfo/swift-evolution-announce</a></span><br></div></blockquote></body></html>