<div dir="ltr"><div><div>With the removal of post/pre-increment/decrement you might as well translate C-style for-loops to something akin to<br><br></div>for var i in 0..<10 {<br> ...<br>}<br><br></div>If more advanced C-style for-loops are needed, I am sure most developers can use a while-loop (as mentioned by Ray Fix) until they get accustomed to Swift’s syntax. <br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 4, 2015 at 11:37 PM, Joe Groff <span dir="ltr"><<a href="mailto:jgroff@apple.com" target="_blank">jgroff@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>You might ease the pain by approximating C-style 'for' by a higher-order function:</div><div><br></div><div>func cStyleFor(@autoclosure init initializer: () -> (), @autoclosure test: () -> Bool, @autoclosure inc: () -> (), body: () throws -> ()) rethrows {</div><div> // left as an exercise</div><div>}</div><div><br></div><div>var i = 0</div><div>cStyleFor(init: i = 0, test: i < 10, inc: ++i) {</div><div> print(i)</div><div>}</div><div><br></div><div>-Joe</div><br><div><blockquote type="cite"><span class=""><div>On Dec 4, 2015, at 2:33 PM, Colin Cornaby <<a href="mailto:colin.cornaby@mac.com" target="_blank">colin.cornaby@mac.com</a>> wrote:</div><br></span><div><div><span class=""><div>I was talking with people in the office about this proposal today, in since there has been such a long discussion already I'll just reply to the top of the tree just to get our take in before the review...</div><div><br></div><div>It's understood that Swift has better, more readable ways to do for loops, but C style for loops reduce friction for getting our C or C++ developers on board with Swift. Unless there is a gain elsewhere to be made in their removal, it would be nice to keep them. As we transition to Swift we can educate developers on better ways to iterate, but it would be nice to have one less thing in the way of getting people writing Swift code.</div><div><br></div><div>We work on a lot of algorithmic code which would be well suited for Swift. And again, I understand that C style for loops are redundant. But it's just one less speed bump in understanding for some of our developers or for porting pure C or C++ code without having to do as much re-validation of algorithms for accidental changes.</div><div><br></div><div>But if it's actively hurting some other part of the language we could probably be talked into it.</div><div><br>On Dec 03, 2015, at 03:32 PM, Erica Sadun <<a href="mailto:erica@ericasadun.com" target="_blank">erica@ericasadun.com</a>> wrote:<br><br></div></span><div><blockquote type="cite"><div style="word-wrap:break-word"><span class="">Does Swift still needs C-style for loops with conditions and incrementers? <div><br></div></span><div><span class=""><div><span><Screen Shot 2015-12-03 at 4.30.15 PM.png></span></div><div><br></div></span><span class=""><div>More Swift-like construction is already available with <i>for-in</i>-statements and <i>stride</i>. </div><div>This would naturally starve the most common point for -- and ++ operators as well.</div></span></div><div><br></div><div>-- E</div><div><br></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=OFgvmg1J6naJevMotmPmRgzA4p1gcL5s2O89Xj3c0DQwWaI2Zkn0T7Ir0ZhZX5JxhOGd3YPVKqo7V694c-2FCbs4q0bD0JoSqDmVKJlXSPFXuXDd-2BrSCkHJtpH2xW9FNCpsnXhG1CXNS-2BYiwa2avrMmz1klqK9v719yPdWuKsBJaZWK1jLmeFzO0xSa2YmruaZcuht7m9Jfq3dmNJI2I0f-2FXBDGxRbOsbfv3np8d7UbdU-3D" alt="" style="min-height:1px;width:1px;border-width:0;padding:0;margin:0" height="1" border="0" width="1"></div></blockquote></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=RoDF4MveSEMYBIqIJA6ub1g8cOZ-2BVYvqV-2FqygPhjPn9dSCJq6hHxaKAHz2SgEMUEdmJq-2FsAifCMjI5P2wUJabdikvDGXS5zaIeiAW9VmUaiGFnyIyDQg2eHpiypFZpLqkwlMcSPttbgMOFlDhKsq7OZYMo2NC9kSDKFKCrEgV5UwEzHq3kVy3cvCkNDjAtbKUGaHHbyeqN4xiVXzGIrvZWzJxd5zQxuKao7pxdgeN1w-3D" alt="" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important" height="1" border="0" width="1">
</div><span class="">
_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></span></div></blockquote></div><br>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=KlmFWKNIEcyPEGx2Wqruu-2FaM6I0anrxIOlKS1pgqec64JmPD57SelWBf8STiBYuH5i3ko-2FtD2CU6chZgK79T9K3b3jBmmA5gMpTX5FF5mQnohQWqc0wkDTtpj-2FuZjbkeuGjx9YAUCDfU8j39LzH9ARiDcAzF3Bn8yEUzw1iLutsMLA-2FFkrnHXyH-2FxtuuASWC4iWLDeixQLwaQDsRNIRipB5PAbcL-2ByGZDjYiIwDQNRc-3D" alt="" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important" height="1" border="0" width="1">
</div>
<br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div>