Hi Erica,

Just a quick side note with regards to:

> Dmitri adds: "You can use AnySequence and AnyGenerator, but they come at a 
> cost of dynamic dispatch for every call.  In this case, if you want this 
> component to be suitable for performance-critical code, I would suggest to 
> avoid them for now."

This is very much true. But since Swift 2.0, that overhead can actually be 
avoided for AnyGenerator given enough context.

Basically, if the producer and consumer of the sequence are in the same module 
and with whole module optimization enabled (or putting all the relevant parts 
in the same file), AnyGenerator can be as fast as a native generator.

It's of limited usefulness and a bit weird to use AnyGenerator instead of 
AnySequence but it can be handy when:
        * performance is critical,
        * you want to use more than one sequence type (with different 
generators)
        * and can't use generic functions to solve your problem...

- Janosch

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to