[Accepted] SE-0007 Remove C-style for-loops with conditions and incrementers


(Douglas Gregor) #1

Hello all,

The review of SE-0007 “Remove C-style for-loops with conditions and incrementers” ran from December 7–10, 2015. The proposal has been accepted for Swift 3.0.

Thank you to everyone who participated in the review process! We had a lot of discussion around this proposal. For the most part, there was agreement that C-style for loops are quite rare in Swift code, and most of the existing uses would be better written as for-in loops. Much of the debate focused on two particular areas where the removal of C-style for loops could cause problems:

  * Some loops are awkward to express cleanly with for-in, such as counting down, and there are advanced uses of C-style for loops that are hard to express otherwise. The core team feels that some of the awkwardness for simple loops (e.g., counting down) should be addressed by improvements in the Standard Library, and that the remaining, more advanced uses are not common enough to justify keeping C-style for loops in the language.

  * Performance of the for-in loop lags behind that of the C-style for loop in some cases. The core team feels that optimizer improvements can close this performance gap, and that ‘while’ loops are an acceptable substitute for performance-critical code where the optimizer isn’t yet eliminating the abstractions used in the for-in loop.

We welcome implementations of this proposal! Because it involves the removal of an existing feature, the implementation will need to be staged across the two upcoming Swift releases:

  * For Swift 2.2: introduce a warning to tell users that the C-style for loop is going away (covered by https://bugs.swift.org/browse/SR-226)
  * For Swift 3.0 (once we branch 2.2): actually remove C-style for loops (covered by https://bugs.swift.org/browse/SR-227)

For reference, the proposal document is here:

  (https://github.com/apple/swift-evolution/blob/master/proposals/0007-remove-c-style-for-loops.md)

  - Doug Gregor, Review Manager


(Erica Sadun) #2

Dear Swift Team and Swift-Evolution members,

I want to send a quick note of appreciation to everyone who participated in this proposal process:

Team, thank you for taking my suggestion seriously and encouraging me to transform my tweet into a now-accepted formal language enhancement.
Doug, thank you for being my proposal manager and guiding SE-0007 through the entire process (and for putting up with my frantic emails and confusion!)
List members, thank you for your feedback both for and against this proposal. It was an honor to have my idea taken seriously and be showered with your thoughtful arguments both for and against.

It's been an incredible learning experience for me. I hope I will continue to be able to contribute to the future of the language.

With warmest regards,

-- Erica

···

On Dec 14, 2015, at 11:37 AM, Douglas Gregor via swift-evolution <swift-evolution@swift.org> wrote:

Hello all,

The review of SE-0007 “Remove C-style for-loops with conditions and incrementers” ran from December 7–10, 2015. The proposal has been accepted for Swift 3.0.

Thank you to everyone who participated in the review process! We had a lot of discussion around this proposal. For the most part, there was agreement that C-style for loops are quite rare in Swift code, and most of the existing uses would be better written as for-in loops. Much of the debate focused on two particular areas where the removal of C-style for loops could cause problems:

  * Some loops are awkward to express cleanly with for-in, such as counting down, and there are advanced uses of C-style for loops that are hard to express otherwise. The core team feels that some of the awkwardness for simple loops (e.g., counting down) should be addressed by improvements in the Standard Library, and that the remaining, more advanced uses are not common enough to justify keeping C-style for loops in the language.

  * Performance of the for-in loop lags behind that of the C-style for loop in some cases. The core team feels that optimizer improvements can close this performance gap, and that ‘while’ loops are an acceptable substitute for performance-critical code where the optimizer isn’t yet eliminating the abstractions used in the for-in loop.

We welcome implementations of this proposal! Because it involves the removal of an existing feature, the implementation will need to be staged across the two upcoming Swift releases:

  * For Swift 2.2: introduce a warning to tell users that the C-style for loop is going away (covered by https://bugs.swift.org/browse/SR-226)
  * For Swift 3.0 (once we branch 2.2): actually remove C-style for loops (covered by https://bugs.swift.org/browse/SR-227)

For reference, the proposal document is here:

  (https://github.com/apple/swift-evolution/blob/master/proposals/0007-remove-c-style-for-loops.md)

  - Doug Gregor, Review Manager

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution