<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>-1 I prefer ".filter"<br><br>Sent from my iPad</div><div><br>On 22 Dec 2015, at 7:13 AM, Jordan Rose via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=utf-8"><div class="">I think Jacob said it already: there's no "x in foo()" construct that you could add a 'where' to. There's just a 'for' loop; part of the syntax for 'for' loops is the keyword 'in' and the keyword 'where'.</div><div class=""><br class=""></div><div class="">Now that doesn't mean we couldn't add this—it's basically a limited/small form of list comprehension—but then I personally say -1. 'filter' is good enough for me.</div><div class=""><br class=""></div><div class="">Jordan</div><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 19, 2015, at 22:10 , Charles Constant via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">Hi Jacob,<div class=""><br class=""></div><div class="">I take it that's a -1 ?</div><div class=""><br class=""></div><div class="">I don't quite&nbsp;understand your example, because y in a "for" loop is an Array. So if I modify your example (I'll rename "y" to "numbers")...</div><div class="">&nbsp;</div><div class="">&nbsp; &nbsp; for x in&nbsp;numbers&nbsp;where x &gt; 2 { }<br class=""></div><div class=""><br class=""></div><div class=""><span style="font-size: 13px;" class="">...my intuition immediately barks "it's a filter!"</span></div><div class=""><span style="font-size: 13px;" class=""><br class=""></span></div><div class="">&nbsp; &nbsp; let valid_numbers = x in numbers where x &gt; 2<br class=""></div><div class=""><br class=""></div><div class="">I realize it's good to have a closure-based solution for map/filter/reduce, so fair enough that we let the filter method exist. Maybe if I understood Swift better (is this related to sequences?) this would all make sense... but with what grasp of Swift I do have, it makes the language feel baroque to have this "where" clause that looks like it ought to instantiate an array, but can't.&nbsp;</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><span style="font-size: 13px;" class=""><br class=""></span></div><div class=""><span style="font-size: 13px;" class=""><br class=""></span></div><div class=""><span style="font-size: 13px;" class=""><br class=""></span></div><div class=""><span style="font-size: 13px;" class=""><br class=""></span></div><div class=""><br class=""></div><div class=""><br class=""></div></div><div class="gmail_extra" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""><div class="gmail_quote">On Sat, Dec 19, 2015 at 9:45 PM, Jacob Bandes-Storch<span class="Apple-converted-space">&nbsp;</span><span dir="ltr" class="">&lt;<a href="mailto:jtbandes@gmail.com" target="_blank" class="">jtbandes@gmail.com</a>&gt;</span><span class="Apple-converted-space">&nbsp;</span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div dir="ltr" class="">It doesn't bother me, because I read it as an additional constraint on the `for` loop rather than an operation being done on the enumerated sequence. That is,<div class=""><br class=""></div><div class="">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span>for x in y where x &gt; 2 { }</div><div class=""><br class=""></div><div class="">is fairly consistent with&nbsp;</div><div class=""><br class=""></div><div class="">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span>if let x = y where x &gt; 2 { }</div><div class=""><br class=""></div><div class="">And you wouldn't expect to be able to do "let x = y where x &gt; 2".</div><div class="gmail_extra"><br clear="all" class=""><div class=""><div class=""><div dir="ltr" class=""><div class="">Jacob Bandes-Storch<br class=""></div></div></div></div><br class=""><div class="gmail_quote"><div class=""><div class="h5">On Sat, Dec 19, 2015 at 8:22 PM, Charles Constant via swift-evolution<span class="Apple-converted-space">&nbsp;</span><span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</span><span class="Apple-converted-space">&nbsp;</span>wrote:<br class=""></div></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div class=""><div class="h5"><div dir="ltr" class="">Thanks Charles ,<div class=""><br class=""></div><div class="">I know it's possible to do the same thing with filter. The syntax I drew attention to would be an alternate way.&nbsp;</div><div class=""><br class=""></div><div class="">My only rationale is that, if it works in one place, it ought to work everywhere. The redundancy bothers me too, but since the concept exists, we may as well allow it everywhere. Otherwise, it's still redundant in a "for" loop (maybe performance is better, but that could be optimized?), but also inconsistent because it seems intuitively like it ought to create a subset whereas in reality it is illegal.</div><div class=""><br class=""></div><div class="">Does it bother anyone else, or am I nitpicking?</div></div></div></div><div class=""><div class=""><div class=""><div class="h5"><div class="gmail_extra"><br class=""><div class="gmail_quote">On Sat, Dec 19, 2015 at 7:52 PM, Charles Srstka<span class="Apple-converted-space">&nbsp;</span><span dir="ltr" class="">&lt;<a href="mailto:cocoadev@charlessoft.com" target="_blank" class="">cocoadev@charlessoft.com</a>&gt;</span><span class="Apple-converted-space">&nbsp;</span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><div class=""><div class=""><blockquote type="cite" class="">On Dec 19, 2015, at 9:43 PM, Charles Constant via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""></blockquote><div class=""><blockquote type="cite" class=""><br class=""><div class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class="">I noticed several weeks ago that the following is illegal:<br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><br class=""></div><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline !important;" class="">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span>let new_arr = el in arr where<span class="">&nbsp;</span></span><a href="http://el.is/" target="_blank" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class="">el.is</a><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline !important;" class="">_foo // illegal</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class="">I assumed it would work because it's consistent with the filtering that exists in a "for" loop, i.e.:</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class="">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span>for el in arr where<span class="">&nbsp;</span><a href="http://el.is/" target="_blank" class="">el.is</a>_foo // legal<br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class="">Is this "new proposal" material? I thought I would check in case it's already on the roadmap, or inherently wrong.</div></div></blockquote></div><br class=""></div></div><div class="">I believe what you want is already possible via the “filter” method.</div><span class=""><font color="#888888" class=""><div class=""><br class=""></div><div class="">Charles</div><div class=""><br class=""></div></font></span></div></blockquote></div><br class=""></div></div></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=P-2BsYbBZHRBuLDBJaL4DIKDNfkkjpROowTyRAObV11qzRaqAqbqp979hECJXGD8pFlX7-2F-2B-2FT-2FSlL-2F5StUcFiVW7HkjK1QDKMmQJiSJzzlaiNPIv4-2F6x13G0c5mGIZX2vZwi9R5RwLYtEe5Y-2FRhRTVadZARgWuBd8hYksyur6TdExBuEUDGCqvrte5a-2B4RtDleg4dOIkfnpvTqwMEgftmfM1mTNFITw-2Ful6vdxVxFYrPk-3D" alt="" width="1" height="1" border="0" style="min-height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" class=""></div></div><br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""><br class=""></blockquote></div><br class=""></div></div></blockquote></div><br class=""></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=ZEz4qHYnXhPr3bBPu-2FxP4tN3HfWKL-2FtJpqkQ0gkOVSA8BF6fg-2FzdNTZoFwLoQoLXmEr1sTZ3N2cyy6LNis91yF6YibOTlnVUcAVr3siZo6fqCpCkbSxI-2FW0qYWlWn85m1kCa6VSzZVynwv-2B2Ez6FuzrUHSxqQuVA-2BnrrnFiRZxwGNyp6PNf6rX5hEKaJxErhRjT5vYzr-2FZUJ-2B3dDibzq6Ybx8ZkQPkrXCOtCSjWNPOE-3D" alt="" width="1" height="1" border="0" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""><span class="Apple-converted-space">&nbsp;</span>_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">swift-evolution mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:swift-evolution@swift.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">swift-evolution@swift.org</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br class="">
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=Vm9j-2B2K6zLqxUFTO82XA8HV2TThDz5lA3-2F-2Fpeujw7DTe1QA1GykWiYicwMTkz6GthbO1CTBOVwn-2BwWT6OLS-2BDPcu3YdP5obleBO6-2BIcfjZxbJUiQKTbzc6j-2FWEzSaX2-2BNhJLWMWAw9EunEVI8PsYyeOjDJX5UjDAD6aJG-2B9Sk-2BFoYF-2BJs4lMfrWOMMerEzWTORdwE4xC5fYyrnCYMPO0NiMS29sWbvt3UhNrMs-2BcsDU-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;">

</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>