<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Agreed, any proposal would come with an accompanying PR. Since the API itself is pretty straightforward, I don't think this will put any undue burden on the reviewers.&nbsp;</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">Austin</div><div><br>On Jan 3, 2016, at 12:09 AM, Dave Abrahams &lt;<a href="mailto:dabrahams@apple.com">dabrahams@apple.com</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=utf-8"><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 2, 2016, at 9:44 PM, Austin Zheng via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hello all,<div class=""><br class=""></div><div class="">Currently there exist at least four 'type-erased' sequence/collection types: AnySequence, AnyForwardCollection, AnyBidirectionalCollection, and AnyRandomAccessCollection.</div><div class=""><br class=""></div><div class="">The three Any*Collection types can be conceptually arranged into a 'ladder', in which collections can be constructed unconditionally from collection types above themselves, and conditionally from collection types below themselves. I've put together a little ASCII image of this here: (<a href="https://gist.github.com/austinzheng/829425242bef1573b668" class="">https://gist.github.com/austinzheng/829425242bef1573b668</a>).</div><div class=""><br class=""></div><div class="">Note that AnySequence doesn't currently fit into this ladder: Any*Collection instances can't easily be constructed from AnySequences. SR-119 (<a href="https://bugs.swift.org/browse/SR-119" class="">https://bugs.swift.org/browse/SR-119</a>) aims to change that. As per that ticket, I propose that we add three promotion APIs, sketched out as following:</div><div class=""><br class=""></div><div class="">extension AnyForwardCollection {</div><div class="">&nbsp; &nbsp; init?&lt;Element&gt;(_: AnySequence&lt;&nbsp;Element&gt;)</div><div class="">}</div><div class=""><br class=""></div><div class=""><div class="">extension AnyBidirectionalCollection {</div><div class="">&nbsp; &nbsp; init?&lt;Element&gt;(_: AnySequence&lt;&nbsp;Element&gt;)</div><div class="">}</div></div><div class=""><br class=""></div><div class=""><div class="">extension AnyRandomAccessCollection {</div><div class="">&nbsp; &nbsp; init?&lt;Element&gt;(_: AnySequence&lt;&nbsp;Element&gt;)</div><div class="">}</div></div><div class=""><br class=""></div><div class="">Like their Any*Collection --&gt; Any*Collection antecedents, these initializers construct a new Any*Collection out of an existing AnySequence, but only if the underlying sequence is compatible, and without copying the underlying sequence.</div><div class=""><br class=""></div><div class="">I'll also have to examine SE-0014 (<a href="https://github.com/apple/swift-evolution/blob/master/proposals/0014-constrained-AnySequence.md" class="">https://github.com/apple/swift-evolution/blob/master/proposals/0014-constrained-AnySequence.md</a>) more closely to see if it has any effects on this proposal.</div><div class=""><br class=""></div><div class="">I plan on submitting a formal proposal at some point (probably by the end of the coming week), but first wish to solicit feedback, opinions, concerns, etc. Thanks for your time.</div></div></div></blockquote><div><br class=""></div>My main concern is whether you can implement it, and do so efficiently. &nbsp;I don’t have a particular reason to think you can’t, but it seems simple enough to check, so IMO such a proposal should come with an implementation.</div><div><br class=""></div><div class="">
-Dave

</div>
<br class=""></div></blockquote></body></html>