[swift-evolution] [Pitch] Retiring `where` from for-in loops
Xiaodi Wu
xiaodi.wu at gmail.com
Mon Jun 13 09:05:18 CDT 2016
On Mon, Jun 13, 2016 at 8:58 AM, Charlie Monroe <charlie at charliemonroe.net>
wrote:
> if-continue. But I gladly took upon for-in-where as soon as I found out
> about it since it's more expressive and simply is less typing.
>
I don't think we use the term 'expressive' in the same way. I understand it
to mean that permitting the expression of more things. But of course,
`where` does only a subset of `guard...continue` or `if...continue`; thus,
less expressive.
>
> On Jun 13, 2016, at 2:24 PM, Xiaodi Wu <xiaodi.wu at gmail.com> wrote:
>
> What did you use before `where` existed?
>
> On Mon, Jun 13, 2016 at 1:29 AM Charlie Monroe 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.
>>
>> -- E
>>
>>
>> Not to undermine this fact, but I believe the fact that `where` can be
>> used in a for loop is not widely known. I didn't know about it until about
>> a month ago (haven't really read much docs, but most people don't either).
>>
>> But after I found out about it, I started using it and it IMHO improved
>> readability of my code. Not by much, but it's the little things that make
>> you smile, right?
>>
>> Many people here argument that `where` is a Swift speciality and needs to
>> be learned by the developer - the alternative is to teach the person what's
>> the proper alternative - that using .filter can have performance impact and
>> that the *correct* way is to use guard within the for loop. And that's IMHO
>> much worse than teaching a person about using `where` within a for loop.
>>
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>
>> _______________________________________________
>> 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/20160613/38145fc9/attachment.html>
More information about the swift-evolution
mailing list