<div dir="ltr"><div>Currently, for-loops admit a "where" clause:<br></div><div><br></div><div> for x in seq <b>where</b> cond {</div><div> ...</div><div> }</div><div><br></div><div> behaves like</div><div><br></div><div> for x in seq {</div><div> if !cond { continue }</div><div> ...</div><div> }</div><div><br></div><div><br></div><div>I'd be interested in a "while" clause:</div><div><br></div><div><div> for x in seq <b>while</b> cond {</div><div> ...</div><div> }</div><div><br></div><div> would behave like</div><div><br></div><div> for x in seq {</div><div> if !cond { break }</div><div> ...</div><div> }</div></div><div><br></div><div><br></div><div>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></div><div><br></div><div>Pros:</div><div>- 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><br></div><div>Cons:</div><div>- It's a new feature.</div><div>- Naming might cause confusion with while-loops.</div><div><br></div><div>Open questions:</div>- How/could it be combined with "where" clauses? Would order matter?<div>- Does anyone else care?</div><div><br></div><div><br></div><div>Thanks,</div><div><div><div class="gmail_signature"><div dir="ltr"><div>Jacob</div></div></div></div>
</div></div>