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

Xiaodi Wu xiaodi.wu at gmail.com
Fri Jun 10 11:31:44 CDT 2016


On Fri, Jun 10, 2016 at 11:23 AM, Sean Heber via swift-evolution <
swift-evolution at swift.org> wrote:

> > And to follow-up to myself once again, I went to my "Cool 3rd Party
> Swift Repos" folder and did the same search. Among the 15 repos in that
> folder, a joint search returned about 650 hits on for-in (again with some
> false positives) and not a single for-in-while use.
>
> Weird. My own Swift projects (not on Github :P) use “where” all the time
> with for loops. I really like it and think it reads *and* writes far better
> as well as makes for nicer one-liners. In one project, by rough count, I
> have about 20 that use “where” vs. 40 in that same project not using
> “where”.
>
> In another smaller test project, there are only 10 for loops, but even so
> one still managed to use where.
>
> Not a lot of data without looking at even more projects, I admit, but this
> seems to suggest that the usage of “where” is going to be very
> developer-dependent. Perhaps there’s some factor of prior background at
> work here? (I’ve done a lot of SQL in another life, for example.)
>

That is worrying if true, because it suggests that it's enabling 'dialects'
of Swift, an explicit anti-goal of the language.


>
> I feel like “where” is a more declarative construct and that we should be
> encouraging that way of thinking in general. When using it, it feels like
> “magic” for some reason - even though there’s nothing special about it. It
> feels like I’ve made the language work *for me* a little bit rather than me
> having to contort my solution to the will of the language. This may be
> highly subjective.
>
> l8r
> Sean
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160610/756c56df/attachment.html>


More information about the swift-evolution mailing list