<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 Dec 31, 2015, at 12:42 AM, Jacob Bandes-Storch via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Currently, for-loops admit a "where" clause:<br class=""></div><div class=""><br class=""></div><div class=""> for x in seq <b class="">where</b> cond {</div><div class=""> ...</div><div class=""> }</div><div class=""><br class=""></div><div class=""> behaves like</div><div class=""><br class=""></div><div class=""> for x in seq {</div><div class=""> if !cond { continue }</div><div class=""> ...</div><div class=""> }</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">I'd be interested in a "while" clause:</div><div class=""><br class=""></div><div class=""><div class=""> for x in seq <b class="">while</b> cond {</div><div class=""> ...</div><div class=""> }</div><div class=""><br class=""></div><div class=""> would behave like</div><div class=""><br class=""></div><div class=""> for x in seq {</div><div class=""> if !cond { break }</div><div class=""> ...</div><div class=""> }</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">This is one area where C-style for-loops would have provided a clean solution (combining multiple conditions with &&), but once they're removed any extra conditions will have to move inside the loop.<br class=""></div><div class=""><br class=""></div><div class="">Pros:</div><div class="">- It's a simple way to express a common piece of control flow that otherwise requires negation and another set of braces.</div>- Its meaning is easy to understand.<div class=""><br class=""></div><div class="">Cons:</div><div class="">- It's a new feature.</div><div class="">- Naming might cause confusion with while-loops.</div><div class=""><br class=""></div><div class="">Open questions:</div>- How/could it be combined with "where" clauses? Would order matter?<div class="">- Does anyone else care?</div></div></div></blockquote><br class=""></div><div>My 2c: it is adding complexity and potential for confusion for very little gain. Also, “where” and “while” are structurally different, because while isn’t a modifier that occurs in many other places. Adding “where” to for loops was justified by a push to improve pattern matching in swift.</div><div><br class=""></div><div>-Chris</div><br class=""></body></html>