<div dir="ltr">What do you mean by "without copying the underlying collection"? Is this specifically for the case where the AnySequence is wrapping a collection (which is not always the case)?<div class="gmail_extra">
<br><div class="gmail_quote">On Mon, Dec 7, 2015 at 2:18 PM, Dmitri Gribenko via swift-dev <span dir="ltr"><<a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">It would require a proposal and a review, but the implementation is<br>
more challenging here than the API design. The proposal would be<br>
trivial, just one extra API, if I'm imagining this correctly.<br>
<span class="HOEnZb"><font color="#888888"><br>
Dmitri<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Mon, Dec 7, 2015 at 2:10 PM, Austin Zheng <<a href="mailto:austinzheng@gmail.com">austinzheng@gmail.com</a>> wrote:<br>
> Would this require a review/proposal, since it involves an API change?<br>
><br>
> On Mon, Dec 7, 2015 at 2:08 PM, Dmitri Gribenko via swift-dev<br>
> <<a href="mailto:swift-dev@swift.org">swift-dev@swift.org</a>> wrote:<br>
>><br>
>> Hi,<br>
>><br>
>> If someone looks for a starter project in the standard library with<br>
>> intermediate complexity (prior experience with Swift generics<br>
>> required), here's one.<br>
>><br>
>> This is in the area of existential sequence and collection wrappers.<br>
>><br>
>> Upgrading AnyForwardCollection to AnyRandomAccessCollection works:<br>
>><br>
>> (swift) AnyRandomAccessCollection(AnyForwardCollection([1,2,3]))<br>
>> // r2 : AnyRandomAccessCollection<Int>? =<br>
>> Optional(Swift.AnyRandomAccessCollection<Swift.Int>(_box:<br>
>> Swift._CollectionBox<Swift.Array<Swift.Int>>))<br>
>><br>
>> Seems like we don't provide APIs to upgrade AnySequence to Any*Collection:<br>
>><br>
>> (swift) AnyRandomAccessCollection(AnySequence([1,2,3]))<br>
>> <REPL Input>:1:1: error: cannot invoke initializer for type<br>
>> 'AnyRandomAccessCollection<_>' with an argument list of type<br>
>> '(AnySequence<Int>)'<br>
>><br>
>> Of course, this should work without copying the underlying collection.<br>
>><br>
>> <a href="https://bugs.swift.org/browse/SR-119" rel="noreferrer" target="_blank">https://bugs.swift.org/browse/SR-119</a><br>
>><br>
>> Dmitri<br>
>><br>
>> --<br>
>> main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if<br>
>> (j){printf("%d\n",i);}}} /*Dmitri Gribenko <<a href="mailto:gribozavr@gmail.com">gribozavr@gmail.com</a>>*/<br>
>> _______________________________________________<br>
>> swift-dev mailing list<br>
>> <a href="mailto:swift-dev@swift.org">swift-dev@swift.org</a><br>
>> <a href="https://lists.swift.org/mailman/listinfo/swift-dev" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-dev</a><br>
><br>
><br>
<br>
<br>
<br>
--<br>
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if<br>
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <<a href="mailto:gribozavr@gmail.com">gribozavr@gmail.com</a>>*/<br>
_______________________________________________<br>
swift-dev mailing list<br>
<a href="mailto:swift-dev@swift.org">swift-dev@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-dev" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-dev</a><br>
</div></div></blockquote></div><br></div></div>