<div style="white-space:pre-wrap">See, the key difference between for...in and .forEach() is that one allows for continue and break and the other doesn&#39;t. Swift is not a live-and-let-live language: if you truly believe that using continue leads to bad code, then propose its removal or the removal of for...in altogether.<br></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Jun 13, 2016 at 11:21 let var go &lt;<a href="mailto:letvargo@gmail.com">letvargo@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">No, I wouldn&#39;t eliminate &#39;continue&#39;. Even though I consider it a sub-optimal solution, I would keep it in the language. Why? A couple of reasons:<div><br></div><div>1) I don&#39;t like it, but even &#39;continue&#39; may be the best available solution in the context of a particular problem. I will look for other options first, but I don&#39;t rule out the possibility that there might come a time when it is the right tool for the job.</div><div><br></div><div>2) Some people like it. Not everyone feels the same way about it as me. Some of the people who like it are better programmers than me. I have a lot to learn, and someday I might discover that I love &#39;continue&#39; after all. Until then, live-and-let-live is what I say. Everyone should control their own flow :) Keep your hands off my &#39;where&#39; and I&#39;ll keep my hands off your &#39;continue&#39; :)</div></div><div dir="ltr"><div><div><div><div><div><br><div class="gmail_quote"><div dir="ltr">On Mon, Jun 13, 2016 at 8:56 AM Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Jun 13, 2016 at 10:44 AM, let var go <span dir="ltr">&lt;<a href="mailto:letvargo@gmail.com" target="_blank">letvargo@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I think we must be reading different discussions.<div><br></div><div>What I have seen in this discussion is the following:</div><div><br></div><div>a) The need to filter a for-in loop doesn&#39;t arise that often; but,</div><div>b) When it does arise, everyone who has chimed in on this thread (except the two people who are proposing the change) thinks that the &quot;where&quot; clause is the clearest, most expressive way to do it.</div><div><br></div><div>Something that would help me get on board with this change is more evidence about what kind of problems it is actually creating.</div><div><br></div><div>As best I can tell, this proposal got started because &quot;somewhere&quot; some new programmers (no one knows how many) expressed some confusion (no one knows how seriously they were confused, or how long it took them to figure it out) about how the where clause worked in a for-in loop. For all we know, once they learned the way it works, they may have said, &quot;Hey that&#39;s cool! I&#39;m gonna use that from now on!&quot;</div><div><br></div><div>In other words, you seem to be talking about removing a feature that is liked by *a lot* people, based on some unsubstantiated reports of user error that may or may not have been totally unsubstantial.</div><div><br></div><div>I don&#39;t want new programmers to be confused, either, but the &quot;where&quot; clause is such a basic programming construct - the keyword is new, but the idea itself is as old as programming - that I don&#39;t mind expecting new programmers to learn how to use it. The learning curve should be incredibly short - it is nothing more than a filter operation.</div><div><br></div><div>There&#39;s something else here that is really important to me, though I don&#39;t know how others feel about it.</div><div><br></div><div>Using the guard...continue approach that you are promoting is a code smell. It puts control-flow logic inside the for-in loop. That is something I have always tried to avoid. I know that the language allows for it, but I believe it is bad programming practice. In fact, if you get rid of the `where` keyword, I&#39;m still not going to use guard...continue. I&#39;ll just filter the collection first and then loop it.</div></div></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>This is quite the statement. It sounds like you&#39;d be for the elimination of `continue`?</div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>It is a code smell for the same reason that messing with the index inside a for;; loop was a code smell. I was always taught never to do this:</div><div><br></div><div>for var i = 0; i &lt; array.count, i++ {</div><div>  if iWantThisToLoopAnExtraTime {</div><div>    i--</div><div>  }</div><div>}</div><div><br></div><div>Why? Because code like that is confusing. It becomes difficult to know how many times the loop will execute, what the looping logic is, etc. Sure, I might get away with it most of the time, but it is bad practice and there is always a better way to do what you want to do. The only thing that keeps you from the better way is laziness.</div><div><br></div><div>The same is true (albeit to a lesser degree) for the guard...continue. It may not be as extreme, but it is still a code smell. It divides the control-flow logic into two parts - one outside the loop, and one inside the loop, and it suddenly becomes twice as easy to miss something.</div><div><br></div><div>Using for-in-where, all of the control-flow logic is on one single line, and once it is known that &quot;where&quot; operates as a filter operation, it all works together in a single, harmonious statement that declares exactly what is going to happen in a way that is totally unambiguous.</div><div><br></div><div>So by getting rid of the &quot;where&quot; clause, I believe that you are actually encouraging bad programming practice. Instead of encouraging the new user to learn this very simple construct that will ultimately make their code safer and more expressive without dividing their control-flow logic unnecessarily into two separate parts, you are encouraging them to just &quot;do what they know&quot;. I think that is terrible, and you are doing them a disservice.</div><div><br></div><div>And from a personal standpoint, you are telling me that I have to write smelly code, even though there is this perfectly good non-smelly option sitting right there, because you don&#39;t want someone else to have to learn something.</div><div><div><div><br><div class="gmail_quote"><div dir="ltr">On Mon, Jun 13, 2016 at 5:29 AM Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="white-space:pre-wrap">I think this discussion has made it pretty plain that what is claimed to be &#39;so useful&#39; is barely ever used. Moreover, it provides no independent uses. The point of these pitches is to sound out arguments, not, as far as I was aware, to take a vote.<br></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Jun 13, 2016 at 1:54 AM Jose Cheyo Jimenez &lt;<a href="mailto:cheyo@masters3d.com" target="_blank">cheyo@masters3d.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div></div><div><span style="background-color:rgba(255,255,255,0)">--1</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)">I think it would be a waste of the community&#39;s time to do a formal review when only two people are in favor of this removal. </span></div><div><br></div><div>&#39;for in where&#39; is so useful especially since we don&#39;t have for;;; loops anymore. I&#39;d say leave this alone; the majority doesn&#39;t want this changed. </div></div><div dir="auto"><div><span style="background-color:rgba(255,255,255,0)"><br></span></div><div><span style="background-color:rgba(255,255,255,0)"><br></span></div><div><br>On Jun 10, 2016, at 10:17 AM, Xiaodi Wu via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br><br></div></div><div dir="auto"><blockquote type="cite"><div><div style="white-space:pre-wrap">I think this idea--if you don&#39;t like it, then you don&#39;t have to use it--is indicative of a key worry here: it&#39;s inessential to the language and promotes dialects wherein certain people use it and others wherein they don&#39;t. This is an anti-goal.<br></div><br></div></blockquote></div><div dir="auto"><blockquote type="cite"><div><div class="gmail_quote"><div dir="ltr">On Fri, Jun 10, 2016 at 12:10 let var go &lt;<a href="mailto:letvargo@gmail.com" target="_blank">letvargo@gmail.com</a>&gt; wrote:<br></div></div></div></blockquote></div><div dir="auto"><blockquote type="cite"><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Leave it in!<div><br><div>It&#39;s a great little tool. I don&#39;t use it very often, but when I do it is because I&#39;ve decided that in the context of that piece of code it does exactly what I want it to do with the maximum amount of clarity.</div><div><br></div></div><div>If you don&#39;t like it, then don&#39;t use it, but I can&#39;t see how it detracts from the language at all.</div><div><br></div><div>The *only* argument that I have heard for removing it is that some people don&#39;t immediately intuit how to use it. I didn&#39;t have any trouble with it at all. It follows one of the most basic programming patterns ever: &quot;For all x in X, if predicate P is true, do something.&quot; The use of the keyword &quot;where&quot; makes perfect sense in that context, and when I read it out loud, it sounds natural: &quot;For all x in X where P, do something.&quot; That is an elegant, succinct, and clear way of stating exactly what I want my program to do.</div><div><br></div><div>I don&#39;t doubt that it has caused some confusion for some people, but I&#39;m not sold that that is a good enough reason to get rid of it. It seems strange to get rid of a tool because not everyone understands how to use it immediately, without ever having to ask a single question. As long as its not a dangerous tool (and it isn&#39;t), then keep it in the workshop for those times when it comes in handy. And even if there is some initial confusion, it doesn&#39;t sound like it lasted that long. It&#39;s more like, &quot;Does this work like X, or does this work like Y? Let&#39;s see...oh, it works like X. Ok.&quot; That&#39;s the entire learning curve...about 5 seconds of curiosity followed by the blissful feeling of resolution.</div></div><br></blockquote></div></div></blockquote></div><div dir="auto"><blockquote type="cite"><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><div dir="ltr">On Fri, Jun 10, 2016 at 9:32 AM Xiaodi Wu via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br></div></div></blockquote></div></div></blockquote></div><div dir="auto"><blockquote type="cite"><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Jun 10, 2016 at 11:23 AM, Sean Heber via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br></div></div></div></blockquote></div></blockquote></div></div></blockquote></div><div dir="auto"><blockquote type="cite"><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>&gt; And to follow-up to myself once again, I went to my &quot;Cool 3rd Party Swift Repos&quot; 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>
<br>
</span></blockquote></div></div></div></blockquote></div></blockquote></div></div></blockquote></div><div dir="auto"><blockquote type="cite"><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Weird. My own Swift projects (not on Github :P) use “where” all the time with for loops. I really like it and think it reads *and* writes far better as well as makes for nicer one-liners. In one project, by rough count, I have about 20 that use “where” vs. 40 in that same project not using “where”.<br>
<br>
In another smaller test project, there are only 10 for loops, but even so one still managed to use where.<br>
<br>
Not a lot of data without looking at even more projects, I admit, but this seems to suggest that the usage of “where” is going to be very developer-dependent. Perhaps there’s some factor of prior background at work here? (I’ve done a lot of SQL in another life, for example.)<br></blockquote></div></div></div></blockquote></div></blockquote></div></div></blockquote></div><div dir="auto"><blockquote type="cite"><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>That is worrying if true, because it suggests that it&#39;s enabling &#39;dialects&#39; of Swift, an explicit anti-goal of the language.</div></div></div></div></blockquote></div></blockquote></div></div></blockquote></div><div dir="auto"><blockquote type="cite"><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
I feel like “where” is a more declarative construct and that we should be encouraging that way of thinking in general. When using it, it feels like “magic” for some reason - even though there’s nothing special about it. It feels like I’ve made the language work *for me* a little bit rather than me having to contort my solution to the will of the language. This may be highly subjective.<br>
<br>
l8r<br>
<span><font color="#888888">Sean<br>
</font></span></blockquote></div></div></div></blockquote></div></blockquote></div></div></blockquote></div><div dir="auto"><blockquote type="cite"><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</div></div></blockquote></div></div></div></blockquote></div></blockquote></div></div></blockquote></div><div dir="auto"><blockquote type="cite"><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div></blockquote></div></div></blockquote></div><div dir="auto"><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></div></blockquote></div>
</blockquote></div></div></div></div></div>
</blockquote></div></div></div></blockquote></div></div></div></div></div></div></div></blockquote></div>