> 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

>       * What is your evaluation of the proposal?

Huge -1.

In my opinion, structuring for-loops to take advantage of “where” can turn a 
confusing or difficult filtering rule into a SQL-like declarative statement 
that’s easier to read and easier to reason about.

The proposal seems to make an assumption that using where conditions makes the 
logic impenetrable since I believe there’s an underlying assumption that it is 
common to chain 3 or 4 or 5 conditions there. In my experience, that is very 
much NOT the case. In fact I would argue that the syntax of “where” and the way 
it is structured encourages brevity and clarification of intent in ways that a 
list of guards and ifs cannot because a bunch of guard/if statements has no 
syntactic pressure limiting their proliferation in the loop’s body whereas the 
“where” construct does.

Usage metrics are not a strong argument to me. I know that argument was also 
partially used to support removal of C-style for-loops (a decision with which I 
strongly support), but in that case I feel there were many other good 
supporting arguments in play. In the case of removing “where”, it seems the 
primary argument is usage stats pulled from a few open source projects (some of 
which may even have code predating the introduction of “where” on for loops) 
and some anecdotal suggestions that it might be confusing the very first time 
someone encounters it without having read the documentation beforehand. The 
latter argument is very weak, IMO, because as far as I can tell, there is zero 
evidence (not even anecdotal) that once a person learns how “for-where” works 
that there is ever confusion about it again or that it is ever a source of bugs 
as a result of confusion.

If this proposal was for replacing for-where with a full fledged Python-ish 
list comprehension kind of construct, then I might have a different opinion. As 
it is, it’s in favor of removing the closest thing we have to them and 
replacing it with nothing.

I could imagine supporting an *adjustment* to for-where’s syntax to this, for 
example:

for x where x < 42 in sequence {
}

However it seemed the discussion was centered almost exclusively around the 
idea of just getting rid of it rather than trying to fix any of the perceived 
flaws it may have.


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

I don’t even agree there’s a problem to solve here.


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

No.


>       * If you have used other languages or libraries with a similar feature, 
> how do you feel that this proposal compares to those?

I’ve used many languages without for-where. After using Swift and for-where, I 
no longer like those languages as much.


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

I was a reasonably active participant in the discussion for a time.


l8r
Sean

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

Reply via email to