[swift-evolution] [swift-evolution-announce] [Review] SE-0105: Removing Where Clauses from For-In Loops
shawnce at gmail.com
Thu Jun 23 10:59:09 CDT 2016
I am -0.5 on removing the where clause. I will note that removing it now -
given the appearing limited usage - shouldn't cause a large disruption to
most users. It may allow us time to think more about it and things related
to it since it can be added back at a later point without breaking swift 3
I personally was bitten by misusing where with a for-in, I had the mental
model that it would abort the loop. To be honest I am not sure why I had
that mental model given long history with SQL where clause and using where
heavily in switch case statements (e.g. acts as a filter). I think for some
uses I had an assumption that the optimizer could prove that the where
would in fact always filter past a certain loop point and that may have
screwed up my mental model in the general case.
If you make such a mistake with where you may never know because from a
line debugging perspective your loop content never gets executed if the
where is violated yet you may still be looping (possibly causing
destructive consumption or a performance issue).
With that said I do find the syntax fairly clean and helpful when using
for-in (if not abused by chaining many together). I don't have a better
name for it, if it stays around I think it should stay named where to align
with where in other constructs in the language.
I do think for completeness we should consider adding 'until' for abort
looping case. We should also consider moving the location of the where (and
potential until) on the other side of 'in'.
One negative to this syntax (assuming not abused) is not being able to
probe things with a line based debugger. Of course many compact constructs
in the language are that way. ...maybe someday lldb and Xcode could allow
for statement scoped breakpoints
On Wed, Jun 22, 2016 at 9:12 PM Chris Lattner <clattner at apple.com> wrote:
> 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:
> Reviews are an important part of the Swift evolution process. All reviews
> should be sent to the swift-evolution mailing list at
> 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
> Thank you,
> -Chris Lattner
> Review Manager
> swift-evolution-announce mailing list
> swift-evolution-announce at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution