[swift-dev] Implementation of Existential Collection (AnySequence and co.)

Pavol Vaskovic pali at pali.sk
Wed Apr 5 11:56:35 CDT 2017


On Wednesday, 5 April 2017 at 16:04, rintaro ishizaki wrote:
> Just FYI
>  
> Implementation of Type Erasers
> https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20160905/002852.html

Thanks for that link!  

This looks like a followup to Chris’s question, so I’m pinging Dmitri to chime in on this.

Bug report: https://bugs.swift.org/browse/SR-4499



For a reproducer, see the benchmark for `run_SuffixAnySequence` - that is utterly dominated by wending elements from the underlying sequence using generic witness table. There is no specialization occurring at all. As I’ve reasoned in my original e-mail, this is understandable - semantics of _AnyIteratorBox used in AnyIterator’s `next` method require virtual dispatch.

Closure based approach to type erasure should’t have such a semantic barrier for optimization - the limit would probably just be currently conservative optimization?

Best regards
Pavol Vaskovic






More information about the swift-dev mailing list