<div dir="ltr">I&#39;d like to propose a small enhancement to the repeat loop.<div><br></div><div>Currently if we want to perform &#39;count&#39; iterations in a loop, we need to do something like:</div><div><br></div><div>for _ in 0 ..&lt; count {</div><div>   //Do something here</div><div>}</div><div><br></div><div>It looks and feels a little awkward. We need to create an unnamed variable, and it&#39;s easy to forget (especially for language newcomers) that the loop starts with 0 and doesn&#39;t include count.</div><div><br></div><div>We can also do:</div><div><br></div><div>var i = 0</div><div>repeat {</div><div>    //Some code</div><div>    i += 1</div><div>} while i &lt; 10</div><div><br></div><div>This is worse, in that it introduces a variable in the outer scope, and puts the repeat count at the end. Plus, if the expression inside the repeat is complex, the value of i may never be incremented, or may be incremented more than once.</div><div><br></div><div><br></div><div>I propose the following:</div><div><br></div><div>repeat count {</div><div>    //Do something here</div><div>}</div><div><br></div><div>It&#39;s cleaner, and IMO clearer what this code is intended to do.</div><div><br></div><div>Naturally &#39;count&#39; should be non-negative. A while clause is not needed, although I could imagine it being supplied, to create a construct such as:</div><div><br></div><div>var ok = true</div><div>repeat numberOfTimes {</div><div>    //Do something, possibly set ok to false</div><div>} while ok</div><div><br></div><div>This would repeat the loop a maximum of  &#39;numberOfTimes&#39;, but could be ended early if some signal &#39;ok&#39; is set to false (or, of course, by a break statement).</div><div><br></div><div>Thoughts?</div><div><br></div><div>Thanks!</div><div>-Jason-</div></div>