It would require a proposal and a review, but the implementation is
more challenging here than the API design.  The proposal would be
trivial, just one extra API, if I'm imagining this correctly.

Dmitri

On Mon, Dec 7, 2015 at 2:10 PM, Austin Zheng <austinzh...@gmail.com> wrote:
> Would this require a review/proposal, since it involves an API change?
>
> On Mon, Dec 7, 2015 at 2:08 PM, Dmitri Gribenko via swift-dev
> <swift-dev@swift.org> wrote:
>>
>> Hi,
>>
>> If someone looks for a starter project in the standard library with
>> intermediate complexity (prior experience with Swift generics
>> required), here's one.
>>
>> This is in the area of existential sequence and collection wrappers.
>>
>> Upgrading AnyForwardCollection to AnyRandomAccessCollection works:
>>
>> (swift) AnyRandomAccessCollection(AnyForwardCollection([1,2,3]))
>> // r2 : AnyRandomAccessCollection<Int>? =
>> Optional(Swift.AnyRandomAccessCollection<Swift.Int>(_box:
>> Swift._CollectionBox<Swift.Array<Swift.Int>>))
>>
>> Seems like we don't provide APIs to upgrade AnySequence to Any*Collection:
>>
>> (swift) AnyRandomAccessCollection(AnySequence([1,2,3]))
>> <REPL Input>:1:1: error: cannot invoke initializer for type
>> 'AnyRandomAccessCollection<_>' with an argument list of type
>> '(AnySequence<Int>)'
>>
>> Of course, this should work without copying the underlying collection.
>>
>> https://bugs.swift.org/browse/SR-119
>>
>> Dmitri
>>
>> --
>> main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
>> (j){printf("%d\n",i);}}} /*Dmitri Gribenko <griboz...@gmail.com>*/
>> _______________________________________________
>> swift-dev mailing list
>> swift-dev@swift.org
>> https://lists.swift.org/mailman/listinfo/swift-dev
>
>



-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <griboz...@gmail.com>*/
_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev

Reply via email to