[Review] SE-0105: Removing Where Clauses from For-In Loops

A *strong* -1. This is actually one of the features of Swift which feels most Swift-y™ to me.

This is a simple and obvious construct. If we do find confusion (which seems to go away once the feature is explained), we should rename as opposed to remove this feature… but honestly I don’t see it being even that big an issue (and I like the name ‘where’).

I just taught this to a class of newbies last week and exactly zero of them had trouble with it. I told my TA that we were debating removing it, and he was horrified. “It is one of the best features of Swift!” he said. I agree. It is one of the things which gives Swift character and makes it fun.

Also note, that I consider the proposed replacement (guard-else-continue) to be bad/dangerous code. I try to avoid continue within loops if at all possible. It is far too easy to lose track of them during a large/complex refactor and introduce bugs (I have been bitten by this a few times). With for-in-where everything is in one spot, which makes refactoring much simpler.

* Is the problem being addressed significant enough to warrant a change to Swift?

No, I don’t think there is an actual problem here.

* Does this proposal fit well with the feel and direction of Swift?

No, it takes away something which makes Swift feel like Swift for me.

The proposed replacement is much worse, and has more opportunity for bugs. If this passes, I would most likely end up pre-filtering the sequence and iterating that, even though it is less performant than for-if-where or the proposed replacement.

How much effort did you put into your review? A glance, a quick reading, or an in-depth study?

I put a great deal of thought into it and read the entire discussion. I have annoyed my friends with rants about how much I dislike this proposal.

Thanks,
Jon

···

Hello Swift community,

The review of "SE-0105: Removing Where Clauses from For-In Loops" begins now and runs through June 29. The proposal is available here:

  https://github.com/apple/swift-evolution/blob/master/proposals/0105-remove-where-from-forin-loops.md

Reviews are an important part of the Swift evolution process. All reviews should be sent to the swift-evolution mailing list at

  https://lists.swift.org/mailman/listinfo/swift-evolution

or, if you would like to keep your feedback private, directly to the review manager.

What goes into a review?

The goal of the review process is to improve the proposal under review through constructive criticism and contribute to the direction of Swift. When writing your review, here are some questions you might want to answer in your review:

  * What is your evaluation of the proposal?
  * Is the problem being addressed significant enough to warrant a change to Swift?
  * Does this proposal fit well with the feel and direction of Swift?
  * If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?
  * How much effort did you put into your review? A glance, a quick reading, or an in-depth study?

More information about the Swift evolution process is available at

  https://github.com/apple/swift-evolution/blob/master/process.md

Thank you,

-Chris Lattner
Review Manager