> On Jun 13, 2016, at 1:23 PM, Charlie Monroe via swift-evolution > <swift-evolution@swift.org> wrote: > >> Moreover, I find it far cleaner to use the where clause that having to >> remember than I have to use the lazy accessor to avoid a performance hit. > > See the benchmarks me and Erica have posted here a few days back - even with > the lazy accessor, if you decided to use filter(_:), you lost 10+% of > performance. Correct way to do this without `where` and without performance > penalization is to use guard within the for-in loop.
10% on a microbenchmark repeater 4000000 times is hardly a justification for going on way or the other. > >> >>>> Le 13 juin 2016 à 06:39, Charlie Monroe via swift-evolution >>>> <swift-evolution@swift.org> a écrit : >>>> >>>> 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@swift.org >>>> https://lists.swift.org/mailman/listinfo/swift-evolution >>> >>> _______________________________________________ >>> swift-evolution mailing list >>> swift-evolution@swift.org >>> https://lists.swift.org/mailman/listinfo/swift-evolution >> >> _______________________________________________ >> swift-evolution mailing list >> swift-evolution@swift.org >> https://lists.swift.org/mailman/listinfo/swift-evolution > > _______________________________________________ > swift-evolution mailing list > swift-evolution@swift.org > https://lists.swift.org/mailman/listinfo/swift-evolution
_______________________________________________ swift-evolution mailing list swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution