<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=""><div><br class=""><blockquote type="cite" class=""><div class="" style="font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16px;"><b class="">Lowered Readability and Maintainability</b></div><div class="" style="font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16px;"><br class=""></div><div class="" style="font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16px;">I have aesthetic reasons for disliking the for-loop. The C-style loop is harder to read especially for those not coming from C-style languages, easier to mess up at edge conditions, and is commonly used for side-effects which, in a language focused on safety, is not a feature to be encouraged. </div><div class="" style="font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16px;"><br class=""></div><div class="" style="font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16px;">For example, one side effect that was mentioned on-list yesterday was the incrementor, which is guaranteed in C-style to execute late:</div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="" style="font-size: 16px;">Roland King writes:</div><blockquote class="" style="font-size: 14px; margin: 0px 0px 0px 40px; border: none; padding: 0px;"><div class="" style="font-size: 16px;"><br class=""></div><div class="" style="font-size: 16px;"><div class="" style="font-family: Palatino-Roman;">for var floatingThing = start ; floatingThing <= end ; floatingThing += delta</div><div class="" style="font-family: Palatino-Roman;">{</div><div class="" style="font-family: Palatino-Roman;"><span class="Apple-tab-span" style="white-space: pre;">        </span>// more than a few lines of code with early escape continues</div><div class="" style="font-family: Palatino-Roman;">}</div><div class="" style="font-family: Palatino-Roman;"><br class=""></div><div class="" style="font-family: Palatino-Roman;">shows intent of the loop very clearly, start, condition and increment all together at the top, and however you loop you always execute the increment part of the statement. Convert that to a while(), if you have a continue in the body, you have a good chance of not incrementing at all, or duplicating the increment code before every continue. So you can’t always nicely turn for into while. I second the point below about the loop variable being local to the for as well, I also like that. </div><div class="" style="font-family: Palatino-Roman;"><br class=""></div></div></blockquote><span class="" style="font-size: 16px;">Late incrementor management is a feature that can be mimicked with defer, as pointed out by several other list members.</span><font face="Palatino-Roman" size="3" class=""><br class=""></font><blockquote class="" style="font-size: 14px; margin: 0px 0px 0px 40px; border: none; padding: 0px;"><div class="" style="font-size: 16px;"><div class=""><br class=""></div></div></blockquote></div></blockquote><div><br class=""></div><div>Defer wouldn’t accomplish the exact same behavior because it would run if an exception was thrown, which is not the same as the last clause of a for loop, but perhaps is close enough.</div><div><br class=""></div><div>The only other concern I would have is not being able to scope my variables to the loop. I didn’t see it addressed, but perhaps its not very important in the end anyway.</div><div><br class=""></div><div>Something like the following might be nice to scope the variable exclusively to the loop.</div><div><br class=""></div><div>for var x = 0 while (someCondition()) {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>// code</div><div>}</div></div></body></html>