<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 10, 2015, at 5:17 PM, David Owens II 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 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=""><div class=""><font face="HelveticaNeue" class=""><b class="">Review of SE-0007</b></font></div><div class=""><font face="HelveticaNeue" class=""><b class=""><br class=""></b></font></div><div class=""><font face="HelveticaNeue" class=""><b class="">* What is your evaluation of the proposal?</b></font></div><div class=""><font face="HelveticaNeue" class=""><br class=""></font></div><div class=""><font face="HelveticaNeue" class="">I am against this change. I’ve seen no consideration of the performance implications that this change brings about. Also, many of the proposed alternatives tend towards using defer as the mechanism to provide consistent increments/decrements. However, this is problematic around the boundary edges as break and throw are not mechanisms that can halt the execution of the defer statement. So unlike the c-style loop that would not perform that code, the alternatives would.</font></div><div class=""><font face="HelveticaNeue" class=""><br class=""></font></div><div class=""><font face="HelveticaNeue" class=""><b class="">* Is the problem being addressed significant enough to warrant a change to Swift?</b></font></div><div class=""><font face="HelveticaNeue" class=""><br class=""></font></div><div class="">No; it offers no alternative solution to maintain the performance that a c-style for-loop ensures. There is no general pattern than can be used to satisfy a c-style loop’s behavior; each proposed alternative has different issues.</div><div class=""><font face="HelveticaNeue" class=""><br class=""></font></div><div class=""><font face="HelveticaNeue" class=""><b class="">* Does this proposal fit well with the feel and direction of Swift?</b></font></div><div class=""><font face="HelveticaNeue" class=""><br class=""></font></div><div class=""><font face="HelveticaNeue" class="">No, it limits the language’s ability to create concise and legible code when the situation does arise for a c-style loop.</font></div><div class=""><font face="HelveticaNeue" class=""><br class=""></font></div><div class=""><font face="HelveticaNeue" class="">This is the alternative to create a loop that matches the same functionality, including preventing the leaking of loop-variables.</font></div><div class=""><font face="HelveticaNeue" class=""><br class=""></font></div></div></div><blockquote 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; margin: 0px 0px 0px 40px; border: none; padding: 0px;"><div class=""><div class=""><div class=""><font class="" face="Menlo">var sum = 0</font></div></div></div><div class=""><div class=""><div class=""><font class="" face="Menlo">for var i = 1000, j = 2000; i > 0 && j > 0; i -= 1, j -= 2 {</font></div></div></div><div class=""><div class=""><div class=""><font class="" face="Menlo"> if i % 2 == 0 { continue }</font></div></div></div><div class=""><div class=""><div class=""><font class="" face="Menlo"> sum += 1</font></div></div></div><div class=""><div class=""><div class=""><font class="" face="Menlo">}</font></div></div></div><div class=""><div class=""><div class=""><font class="" face="Menlo">print(sum)</font></div></div></div></blockquote><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=""><div class=""><font face="HelveticaNeue" class=""><br class=""></font></div><div class=""><font face="HelveticaNeue" class="">// versus<br class=""><br class=""></font></div></div></div><blockquote 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; margin: 0px 0px 0px 40px; border: none; padding: 0px;"><div class=""><div class=""><div class=""><font class=""><font face="Menlo" class="">var sum = 0</font></font></div></div></div><div class=""><div class=""><div class=""><font class=""><font face="Menlo" class=""><br class=""></font></font></div></div></div><div class=""><div class=""><div class=""><font class=""><font face="Menlo" class="">if true { // some arbitrary scope mechanism is needed to contain i and j</font></font></div></div></div><div class=""><div class=""><div class=""><font class=""><font face="Menlo" class=""> var i = 1000, j = 2000</font></font></div></div></div><div class=""><div class=""><div class=""><font class=""><font face="Menlo" class=""> while i > 0 && j > 0 {</font></font></div></div></div><div class=""><div class=""><div class=""><font class=""><font face="Menlo" class=""> defer {</font></font></div></div></div><div class=""><div class=""><div class=""><font class=""><font face="Menlo" class=""> i -= 1</font></font></div></div></div><div class=""><div class=""><div class=""><font class=""><font face="Menlo" class=""> j -= 2</font></font></div></div></div><div class=""><div class=""><div class=""><font class=""><font face="Menlo" class=""> }</font></font></div></div></div><div class=""><div class=""><div class=""><font class=""><font face="Menlo" class=""> </font></font></div></div></div><div class=""><div class=""><div class=""><font class=""><font face="Menlo" class=""> if i % 2 == 0 { continue }</font></font></div></div></div><div class=""><div class=""><div class=""><font class=""><font face="Menlo" class=""> sum += 1</font></font></div></div></div><div class=""><div class=""><div class=""><font class=""><font face="Menlo" class=""> }</font></font></div></div></div><div class=""><div class=""><div class=""><font class=""><font face="Menlo" class="">}</font></font></div></div></div><div class=""><div class=""><div class=""><font class=""><font face="Menlo" class=""><br class=""></font></font></div></div></div><div class=""><div class=""><div class=""><font class=""><font face="Menlo" class="">print(sum)</font></font></div></div></div></blockquote><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=""><div class=""><br class=""></div><div class=""><font face="HelveticaNeue" class="">To me, that is not a fair trade-off; maybe if the defer pattern could be used at all times and the leaking of the loop-variables was considered ok. There are some ways to consolidate the code so that it takes up less visual space, but I don’t do that for other constructs, so I don’t think that is a valid thing to try and do here. Also, the use of defer in this context is a somewhat of a trick that I’m not sure is even a good pattern to promote as it can lead to boundary-case crashes.</font></div><div class=""><font face="HelveticaNeue" class=""><br class=""></font></div><div class=""><font face="HelveticaNeue" class="">This is unsafe code:</font></div><div class=""><font face="HelveticaNeue" class=""><br class=""></font></div></div></div><blockquote 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; margin: 0px 0px 0px 40px; border: none; padding: 0px;"><div class=""><div class=""><div class=""><font class=""><div class=""><div class=""><div class=""><font face="Menlo" class="">var sum = 0</font></div></div></div></font></div></div></div><div class=""><div class=""><div class=""><font class=""><div class=""><div class=""><div class=""><font face="Menlo" class="">var i: UInt = 1000</font></div></div></div></font></div></div></div><div class=""><div class=""><div class=""><font class=""><div class=""><div class=""><div class=""><font face="Menlo" class="">while i >= 0 {</font></div></div></div></font></div></div></div><div class=""><div class=""><div class=""><font class=""><div class=""><div class=""><div class=""><font face="Menlo" class=""> defer {</font></div></div></div></font></div></div></div><div class=""><div class=""><div class=""><font class=""><div class=""><div class=""><div class=""><font face="Menlo" class=""> i -= 1</font></div></div></div></font></div></div></div><div class=""><div class=""><div class=""><font class=""><div class=""><div class=""><div class=""><font face="Menlo" class=""> }</font></div></div></div></font></div></div></div><div class=""><div class=""><div class=""><font class=""><div class=""><div class=""><div class=""><font face="Menlo" class=""> if i == 0 {</font></div></div></div></font></div></div></div><div class=""><div class=""><div class=""><font class=""><div class=""><div class=""><div class=""><font face="Menlo" class=""> print("zero has been reached!")</font></div></div></div></font></div></div></div><div class=""><div class=""><div class=""><font class=""><div class=""><div class=""><div class=""><font face="Menlo" class=""> break</font></div></div></div></font></div></div></div><div class=""><div class=""><div class=""><font class=""><div class=""><div class=""><div class=""><font face="Menlo" class=""> }</font></div></div></div></font></div></div></div><div class=""><div class=""><div class=""><font class=""><div class=""><div class=""><div class=""><font face="Menlo" class=""><br class=""></font></div></div></div></font></div></div></div><div class=""><div class=""><div class=""><font class=""><div class=""><div class=""><div class=""><font face="Menlo" class=""> if i % 2 == 0 { continue }</font></div></div></div></font></div></div></div><div class=""><div class=""><div class=""><font class=""><div class=""><div class=""><div class=""><font face="Menlo" class=""> sum += 1</font></div></div></div></font></div></div></div></blockquote><blockquote 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; margin: 0px 0px 0px 40px; border: none; padding: 0px;"><div class=""><div class=""><div class=""><font class=""><div class=""><div class=""><div class=""><font face="Menlo" class="">}</font></div></div></div></font></div></div></div></blockquote><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=""><div class=""><font class=""><div class=""><div class=""><div class=""><font face="Menlo" class=""><br class=""></font></div></div></div><div class="" style="font-family: Helvetica;"><div class=""></div></div></font></div><div class=""><font face="HelveticaNeue" class="">The defer statement is still executed, so now I need to come up with a different pattern to handle this type of problem.</font></div><div class=""><font face="HelveticaNeue" class=""><br class=""></font></div><div class=""><font face="HelveticaNeue" class=""><b class="">* If you have you used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?</b></font></div><div class=""><font face="HelveticaNeue" class=""><br class=""></font></div><div class=""><font face="HelveticaNeue" class="">n/a</font></div><div class=""><font face="HelveticaNeue" class=""><br class=""></font></div><div class=""><font face="HelveticaNeue" class=""><b class="">* How much effort did you put into your review? A glance, a quick reading, or an in-depth study?</b></font></div><div class=""><br class=""></div></div></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;">A few hours. I’ve read the proposal multiple times and followed the mail threads. I’ve also done some basic performance analysis (attached mail) on the problem for some of the “improved” versions of the loop construct.</div></div></blockquote><div><br class=""></div><div>Performance is definitely a consideration; we already reverted a pull request that remove C-style fors from the standard library. I believe Andy is currently looking into where the regressions come from. stride(...) performing poorly seems like something we should fix regardless, since that's arguably the idiomatic way to write such loops and ought to perform well. I agree we should investigate ways to ensure common loops over ranges or strides perform reasonably at -Onone if we move forward with this.</div><div><br class=""></div><div>-Joe</div><br class=""><blockquote type="cite" class=""><div class=""><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;">-David</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;"><br class=""></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><span id="cid:067F86E5-BA8D-48DB-8545-69A1F551E467"><SE-0007 Remove C-style for-loops with conditions and incrementers - Performance Consideration.eml></span><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><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;"><br class=""></div><div 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;" class=""><blockquote type="cite" class=""><div class="">On Dec 7, 2015, at 12:44 PM, Douglas Gregor <<a href="mailto:dgregor@apple.com" class="">dgregor@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hello Swift community,<br class=""><br class="">The review of "Remove C-style for-loops with conditions and incrementers” begins now and runs through Thursday, December 10th. The proposal is available here:<div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span><a href="https://github.com/apple/swift-evolution/blob/master/proposals/0007-remove-c-style-for-loops.md" class="">https://github.com/apple/swift-evolution/blob/master/proposals/0007-remove-c-style-for-loops.md</a></div><div class=""><br class=""></div><div class="">Reviews are an important part of the Swift evolution process. All reviews should be sent to the swift-evolution mailing list at</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div><div class=""><br class=""></div><div class="">or, if you would like to keep your feedback private, directly to the review manager.</div><div class=""><br class=""></div><div class="">What goes into a review?</div><div class=""><br class="">The goal of the review process is to improve the proposal under review through constructive criticism and, eventually, determine the direction of Swift. When writing your review, here are some questions you might want to answer in your review:<br class=""><br class=""><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>* What is your evaluation of the proposal?<br class=""></div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>* Is the problem being addressed significant enough to warrant a change to Swift?<br class=""></div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>* Does this proposal fit well with the feel and direction of Swift?<br class=""></div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>* If you have you used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?<br class=""></div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>* How much effort did you put into your review? A glance, a quick reading, or an in-depth study?<br class=""></div><br class=""></div><div class="">More information about the Swift evolution process is available at</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span><a href="https://github.com/apple/swift-evolution/blob/master/process.md" class="">https://github.com/apple/swift-evolution/blob/master/process.md</a></div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>Cheers,</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>Doug Gregor</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>Review Manager</div><div class=""><br class=""></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=nE9rxSXA5G4kxsTVkgv43pXkLx-2B36P-2BPNJufHeY0dgcd-2BZpVwzBBnPsWIIheUPhm2HJqeyeE7Z4nIJP3rw91XntJL-2BCDo0DBumQKM6RXQy7ogk2gjU-2B94fosGVCm-2BJeQDjrGc3sMzkxtf2s0ndsXokfVaofenG1mGZ1NmNRX5LwxuwTiueytQM02tDCYg1V5ryjcw43hu8A4pRA9adr9Qw-3D-3D" alt="" width="1" height="1" border="0" class="" style="height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;"></div>_______________________________________________<br class="">swift-evolution-announce mailing list<br class=""><a href="mailto:swift-evolution-announce@swift.org" class="">swift-evolution-announce@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution-announce" class="">https://lists.swift.org/mailman/listinfo/swift-evolution-announce</a><br class=""></div></blockquote></div><br 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;"><span 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; float: none; display: inline !important;" class="">_______________________________________________</span><br 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;" class=""><span 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; float: none; display: inline !important;" class="">swift-evolution mailing list</span><br 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;" class=""><a href="mailto:swift-evolution@swift.org" 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;" class="">swift-evolution@swift.org</a><br 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;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" 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;" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br class=""></body></html>