<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I wonder how reactionary I will become when Swift is 5 years old :)&nbsp;</div><div class=""><br class=""></div><div class="">I goggled a bit, to get some context on the use of “where” in mathematics. I was surprised to learn that and the use of “where” in mathematics is disliked by some mathematicians for its lack of precision:</div><div class=""><br class=""></div><blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class=""><div class=""><p style="margin: 0px 0px 1em; padding: 0px; border: 0px; font-size: 15px; clear: both; color: rgb(36, 39, 41); font-family: Georgia, 'Times New Roman', Times, serif;" class="">In his famous paper&nbsp;<a href="http://www.math.uh.edu/~tomforde/Books/Halmos-How-To-Write.pdf" rel="nofollow" style="margin: 0px; padding: 0px; border: 0px; color: rgb(20, 93, 138); text-decoration: none; cursor: pointer;" class="">How to write mathematics</a>, P.R. Halmos says the following about "where"</p></div><div class=""><blockquote style="margin: 0px 0px 10px; padding: 10px; border-width: 0px 0px 0px 2px; border-left-style: solid; border-left-color: rgb(255, 235, 142); font-size: 15px; quotes: none; background-color: rgb(255, 249, 227); color: rgb(36, 39, 41); font-family: Georgia, 'Times New Roman', Times, serif;" class=""><div style="margin: 0px; padding: 0px; border: 0px; clear: both;" class="">"Where" is usually a sign of a lazy afterthought that should have been thought through before.&nbsp;</div></blockquote></div></blockquote><blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class="">From&nbsp;<a href="http://math.stackexchange.com/questions/1304270/math-symbol-for-where" class="">http://math.stackexchange.com/questions/1304270/math-symbol-for-where</a></blockquote><div class=""><br class=""></div><div class="">So you may in good company in your concerns about the use of this word.</div><div class=""><br class=""></div><div class="">Taking a clue from this, perhaps a less vague term would clarify things for loops:</div><div class=""><br class=""></div><div class="">Current ‘where’ syntax</div><div class=""><br class=""></div><div class=""><div class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">```</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">for</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;i&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">in</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);" class="">arr</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">where</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;i%</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">2</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;==&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">0</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;{</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp; &nbsp;&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(61, 29, 129);" class="">print</span><span style="font-variant-ligatures: no-common-ligatures;" class="">( i )</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">}</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""></span><div style="font-family: Helvetica; font-size: 12px;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">```</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><br class=""></span></div></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class="">can be rewritten (using the same variable name in the closure):</div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><br class=""></div><div class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">```</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">for</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;i&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">in</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);" class="">arr</span><span style="font-variant-ligatures: no-common-ligatures;" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(61, 29, 129);" class="">filter</span><span style="font-variant-ligatures: no-common-ligatures;" class="">({(i)&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">in</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;i%</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">2</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;==&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">0</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;}) {</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp; &nbsp;&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(61, 29, 129);" class="">print</span><span style="font-variant-ligatures: no-common-ligatures;" class="">( i )</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">}</span></div></div><div class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">```</span></div><div class=""><br class=""></div><div class="">There area many extra characters in the second version. ‘i’ is already bound, so the binding (if that is the correct term) in the filter clause doesn’t add any information. The non-escaping closure requires a set of parens and a set of braces.</div><div class=""><br class=""></div><div class="">What if a new keyword is introduced as a shorthand for using ‘filter’ in this way:</div><div class=""><br class=""></div><div class="">&nbsp;```</div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">for</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;i&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">in</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);" class="">arr</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">filteredby</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;i%</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">2</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;==&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">0</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;{</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp; &nbsp;&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(61, 29, 129);" class="">print</span><span style="font-variant-ligatures: no-common-ligatures;" class="">( i )</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">}</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><div style="font-family: Helvetica; font-size: 12px;" class="">&nbsp;```</div><div class=""><br class=""></div><span style="font-variant-ligatures: no-common-ligatures;" class=""></span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class="">or perhaps, keeping the closure syntax and reusing the variable binding:</div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><br class=""></div><div class="">&nbsp;```</div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">for</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;i&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">in</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);" class="">arr</span><span style="font-variant-ligatures: no-common-ligatures;" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">filteredby{&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures;" class="">i%</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">2</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;==&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">0</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;<font color="#bb2ca2" class="">}&nbsp;</font></span>{</div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp; &nbsp;&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(61, 29, 129);" class="">print</span><span style="font-variant-ligatures: no-common-ligatures;" class="">( i )</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">}</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""></span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo;" class=""><span style="font-family: Helvetica; font-size: 12px;" class="">```</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Jun 10, 2016, at 1:08 PM, Erica Sadun 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=""><br class=""><blockquote type="cite" class="">On Jun 10, 2016, at 1:06 PM, Rob Norback via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class="">Following Brent's logic that the for-in where should mimic the switch statement functionality, then this example:<br class=""><br class="">for (eachKey, eachValue)&nbsp;<br class="">where eachValue &gt; 5&nbsp;<br class="">in theKeyValuePairs {... }<br class=""><br class=""></blockquote><br class="">&lt;squish&gt;<br class=""><br class="">I finally convinced myself of which direction I wanted to go: <a href="https://github.com/apple/swift-evolution/pull/362/files" class="">https://github.com/apple/swift-evolution/pull/362/files</a><br class=""><br class="">Related blog post here: <a href="http://ericasadun.com/2016/06/10/swift-where-oh-where-can-my-where-clause-be/" class="">http://ericasadun.com/2016/06/10/swift-where-oh-where-can-my-where-clause-be/</a><br class=""><br class="">Big thanks to Brent and Wux.<br class=""><br class="">-- E<br class=""><br class=""><br class=""><br class=""><br class="">_______________________________________________<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</div></blockquote></div><div><blockquote type="cite" class=""><div class="">On Jun 10, 2016, at 1:08 PM, Erica Sadun 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 class=""><br class=""><blockquote type="cite" class="">On Jun 10, 2016, at 1:06 PM, Rob Norback via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class="">Following Brent's logic that the for-in where should mimic the switch statement functionality, then this example:<br class=""><br class="">for (eachKey, eachValue) <br class="">where eachValue &gt; 5 <br class="">in theKeyValuePairs {... }<br class=""><br class=""></blockquote><br class="">&lt;squish&gt;<br class=""><br class="">I finally convinced myself of which direction I wanted to go: <a href="https://github.com/apple/swift-evolution/pull/362/files" class="">https://github.com/apple/swift-evolution/pull/362/files</a><br class=""><br class="">Related blog post here: <a href="http://ericasadun.com/2016/06/10/swift-where-oh-where-can-my-where-clause-be/" class="">http://ericasadun.com/2016/06/10/swift-where-oh-where-can-my-where-clause-be/</a><br class=""><br class="">Big thanks to Brent and Wux.<br class=""><br class="">-- E<br class=""><br class=""><br class=""><br class=""><br class="">_______________________________________________<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></div></blockquote></div><br class=""></body></html>