[swift-evolution] [Pitch] Retiring `where` from for-in loops

Jonathan Hull jhull at gbis.com
Fri Jun 10 21:25:56 CDT 2016

Please leave this feature in!

One of the places I get bitten the most during refactoring is somehow missing a ‘continue’ statement inside the loop (and I hear that is a common issue).  For-in-where lets me guard against that problem in simple cases.  

I also find that it is often the clearest way to capture the semantics of what I want.  I find it extremely readable and compact. Everything is all in one place :-)

As for the issue of “dialects”, it really just feels like people are trying to force their particular pet coding style on everyone else.  Should we get rid of .forEach() as well?  Sometimes languages have more than one way to do something, and it is up to the programmer to pick the form that is clearest in the context of use...


> I respect that anti-goal, but I think being over-rigid about limiting
> developers' choice of expression is also an anti-goal.
> To me, it is like guard statements vs. if-let statements. Some people find
> one to be more clear than the other. Often times the best choice depends on
> the context. Sometimes a guard statement can be re-written as an if-let
> statement in a way that makes the code more clear, and vice versa. And
> different people will inevitably have different personal preferences -
> their own "style", if you will - and will favor one over the other. But it
> would be a mistake to force everyone into one box in order to prevent the
> fracturing of the Swift community into "dialects."
> But most importantly (and this is really the kicker for me) there are times
> when the "where" syntax provides the maximum amount of clarity in the
> context of my code, and I don't want to lose that expressive power.
>> On Fri, Jun 10, 2016 at 10:17 AM Xiaodi Wu <xiaodi.wu at gmail.com <https://lists.swift.org/mailman/listinfo/swift-evolution>> wrote:
>> > I think this idea--if you don't like it, then you don't have to use it--is
>> > indicative of a key worry here: it's inessential to the language and
>> > promotes dialects wherein certain people use it and others wherein they
>> > don't. This is an anti-goal.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160610/868e4d6e/attachment.html>

More information about the swift-evolution mailing list