Side question: is there going to be any situation where I’m iterating through a
sequence/collection that I wouldn’t want to always use `lazy`? Is `lazy`
*always* going to be more efficient than the array-creating defaults when the
result is iterated?
For instance, something much better than this terrible syntax:
for a in sequence where .filter({ $0 > 5 }).map({ $0 * 2 }) {
print(a)
}
It would be up to the compiler what calls it turns that into, possibly it could
make a certain whitelist of transformations (filter, map) as efficient as using
`for … where` or `guard` today? Or it could simply make use of `lazy`.
`for` is already hiding ‘magic’ by calling `makeIterator()`, why can’t it do
more ‘magic’, especially since `lazy` is a member of `Sequence` just like
`makeIterator()`.
Anyway, something for the future after Swift 3.0.
Patrick
> On 28 Jun 2016, at 1:58 AM, Erica Sadun via swift-evolution
> <[email protected]> wrote:
>
> Yeah, kicking myself over that. Can't Swift remind me to add `lazy`
> by emitting a warning or something? I keep assuming certain things are
> naturally lazy and then have to go back and de-eagerize.
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution