<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jun 8, 2016, at 9:23 PM, Brent Royal-Gordon via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><div class=""><div class="">The original sin here was in connecting the `where` clause to the for loop's sequence expression, rather than its pattern. If `where` were positioned right after the loop variable:<br class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>for eachValue where someCondition(eachValue) in theValues { … }<br class=""><br class="">It would be much clearer that `where` constrains the values seen by the loop body.<br class=""><br class="">I'm not sure why the `where` clause was placed where it is. I suspect it has something to do with the `where` clause potentially being more complex than the sequence expression, but I was not in the room where it happened, so that's idle speculation.<br class=""></div></div></blockquote></div><br class=""><div class=""><br class=""></div><div class="">I still think `where` should probably be removed from for loops for the reasons</div><div class="">I lay out in the other thread (just use guards, lower confusion, increase readability), </div><div class="">but you're right. There's something wrong in the way that patterns work outside</div><div class="">switch statements.</div><div class=""><br class=""></div><div class=""><i class="">Switch statement grammar:</i></div><div class=""><span style="font-family: Menlo;" class="">case_item_list : pattern where_clause? | pattern where_clause? ',' case_item_list </span></div><div class=""><div class=""><font face="Menlo" class="">(with inferred <b class="">initializer</b> <b class="">at the end</b>)</font></div></div><div class=""><br class=""></div><div class="">vs</div><div class=""><br class=""></div><div class=""><i class="">Case condition grammar:</i></div><div class=""><div class=""><font face="Menlo" class="">case_condition : 'case' pattern initializer where_clause?</font></div><div class=""><font face="Menlo" class="">(with the <b class="">initializer before the where clause</b>) </font></div></div><div class=""><br class=""></div><div class="">To match, the case_condition should have been:</div><div class=""><br class=""></div><div class=""><div class=""><font face="Menlo" class="">case_condition : 'case' pattern where_clause? </font><span style="font-family: Menlo;" class="">initializer</span></div></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class="">If SE-0099 is re-evaluated, and I have a strong sense there's a quorum of folk who want </div><div class="">their `where` clauses, this would introduce more consistent use across the language. </div><div class=""><br class=""></div><div class="">I plan to stay out of the "oh where oh where can my where clause be" argument. </div><div class="">I did want to throw in my observations about the inconsistencies between the </div><div class="">grammars. Kudos, Brent for spotting that.</div><div class=""><br class=""></div><div class="">-- E</div><div class=""><br class=""></div></body></html>