<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div>On Fri, Jun 10, 2016, at 11:49 AM, Erica Sadun via swift-evolution wrote:<br></div>
<blockquote type="cite"><div>&nbsp;<br></div>
<div><blockquote type="cite"><div>On Jun 10, 2016, at 9:24 AM, Erica Sadun &lt;<a href="mailto:erica@ericasadun.com">erica@ericasadun.com</a>&gt; wrote:<br></div>
<div>&nbsp;<br></div>
<div><div style="word-wrap:break-word;-webkit-line-break:after-white-space;"><div>&nbsp;<br></div>
<div><blockquote type="cite"><div>On Jun 10, 2016, at 9:22 AM, Erica Sadun via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br></div>
<div>&nbsp;<br></div>
<div><div style="word-wrap:break-word;-webkit-line-break:after-white-space;"><div>&nbsp;<br></div>
<div><blockquote type="cite"><div>On Jun 10, 2016, at 8:02 AM, Xiaodi Wu via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br></div>
<div>&nbsp;<br></div>
<div><div dir="ltr"><div>On Fri, Jun 10, 2016 at 7:18 AM, Haravikk <span dir="ltr">&lt;<a href="mailto:swift-evolution@haravikk.me">swift-evolution@haravikk.me</a>&gt;</span> wrote:<br></div>
<div><div><blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204, 204, 204);padding-left:1ex;"><div style="word-wrap:break-word;"><div><div>&nbsp;<br></div>
<blockquote type="cite"><div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;" dir="ltr"><div><div><div><span>* The word "where" does not consistently imply `break` or `continue`. In current Swift, `where` implies `break` in the context of a `while` loop and `continue` in the context of a `for` loop. Some users intuitively guess the correct meaning in each context, while others guess the wrong meaning. Therefore, the only way to learn for sure what `where` means in any context is to read the rulebook. That, by definition, means that this is unintuitive.</span><br></div>
</div>
</div>
</div>
</div>
</blockquote><div>&nbsp;<br></div>
<div>&nbsp;<br></div>
<div>This is an argument for renaming the where keyword on for loops to be more clear, or to somehow integrate continue/break to be more explicit about what the developer intends for it to do.<br></div>
</div>
</div>
</blockquote><div>&nbsp;<br></div>
<div>Sure: I conclude that the keyword should be *either* removed *or* reformed; both outcomes could address the issue.<br></div>
</div>
</div>
</div>
</div>
</blockquote><div>&nbsp;<br></div>
<div>This is my stance as well and I reserve the right to flit between both choices until we've fully talked it through.<br></div>
</div>
<div>&nbsp;<br></div>
<div>One more data point.&nbsp;<br></div>
<div>&nbsp;<br></div>
<div>In the standard library there are just under 950 uses of "for in loops". There are 3 uses of "for in while" :<br></div>
<div>&nbsp;<br></div>
<div><div><span class="font" style="font-family:Menlo">private/StdlibUnittest/StdlibUnittest.swift.gyb: &nbsp; &nbsp;for j in instances.indices where i != j {</span><br></div>
<div><span class="font" style="font-family:Menlo">public/core/Algorithm.swift: &nbsp;for value in rest where value &lt; minValue {</span><br></div>
<div><span class="font" style="font-family:Menlo">public/core/Algorithm.swift: &nbsp;for value in rest where value &gt;= maxValue {</span><br></div>
<div>&nbsp;<br></div>
<div>-- Erica<br></div>
</div>
</div>
</div>
</blockquote></div>
<div>Actually a slight correction to that. I forgot to add the space after "in" on the first search. It's just over 600 and 3. Among the 600 are a few false positives but not many.<br></div>
<div>&nbsp;<br></div>
<div>-- E<br></div>
</div>
</div>
</blockquote></div>
<div>And to follow-up to myself once again, I went to my "Cool 3rd Party Swift Repos" folder and did the same search. Among the 15 repos in that folder, a joint search returned about 650 hits on for-in (again with some false positives) and not a single for-in-while use.<br></div>
</blockquote><div>&nbsp;<br></div>
<div>I have access to 3 closed-source enterprise applications, iOS 9 and 100% Swift 2.2. Each of them respectively have one "for in loop"; each one makes use of a "where" clause.<br></div>
<div>&nbsp;<br></div>
<div>Two of the applications are maintained/written by someone other than myself. I wanted to audit them to see if those developers used "for in" correctly or incorrectly; indeed they were all correctly used to filter an Array. Though I cannot rule out they did not stumble into correct use of the `where` clause.<br></div>
<div>&nbsp;<br></div>
<div>More food for thought. Looking at the Git history I realized one of them actually was refactored from something that looked like:<br></div>
<div>&nbsp;<br></div>
<div>let a = [3, 1, 2].sort()<br></div>
<div>a.filter({ $0 &lt;= 2 }).forEach({ print($0) })<br></div>
<div>&nbsp;<br></div>
<div>to<br></div>
<div>&nbsp;<br></div>
<div>let a = [3, 1, 2].sort()<br></div>
<div>for i in a where i &lt;= 2 { print(i) }<br></div>
<div>&nbsp;<br></div>
<div>I'm reasonably confident when I say the developers of this code have never heard of swift-evolution let alone participated in it.<br></div>
<div>&nbsp;<br></div>
<div>Obviously this is anecdotal evidence. It could be that `where` clause is "easy to understand" _or_ equally likely that our hiring process does a great job of selecting a heterogenous population of developers with certain backgrounds that lead to similar code when faced with similar problems.<br></div>
<div>&nbsp;</div>
<div>You know what strikes me about this whole argument? "[This argument] is like a rocking chair: it gives [us] something to do but [does not get us] anywhere". - Someone Else<br></div>
<div>&nbsp;</div>
<div>If this is an example of the pressing/priority issues facing the Swift language today then I say lets all take a long weekend to bask in the glow of this momentous occasion. Then meet back here in 2 years.<br></div>
<div>&nbsp;</div>
<div>Change it or do not change it. I do not imagine it matters either way in 5 years. That having been said though I do think this argument, and others similar to it, are important because I think they run deeper than the syntax. I think they speak to the ethos of this community. With that I think we should think long and hard about this process and what it speaks to in terms of precedence and our collective priorities.<br></div>
<div>&nbsp;<br></div>
<blockquote type="cite"><div>&nbsp;<br></div>
<div>-- E<br></div>
<div><u>_______________________________________________</u><br></div>
<div>swift-evolution mailing list<br></div>
<div><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br></div>
<div><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div>
</blockquote><div>&nbsp;<br></div>
</body>
</html>