[swift-evolution] Why doesn't Collection's SubSequence conform to Collection?
Huon Wilson
huon at apple.com
Mon Feb 13 17:48:28 CST 2017
The lines just after the current declaration show the desired version, which is waiting on two generics features that are in the pipeline:
// FIXME(ABI)#98 (Recursive Protocol Constraints):
// FIXME(ABI)#99 (Associated Types with where clauses):
// associatedtype SubSequence : Collection
// where
// Iterator.Element == SubSequence.Iterator.Element,
// SubSequence.Index == Index,
// SubSequence.Indices == Indices,
// SubSequence.SubSequence == SubSequence
//
// (<rdar://problem/20715009 <rdar://problem/20715009>> Implement recursive protocol
// constraints)
//
// These constraints allow processing collections in generic code by
// repeatedly slicing them in a loop.
Huon
> On Feb 13, 2017, at 13:42, Charles Srstka via swift-evolution <swift-evolution at swift.org> wrote:
>
> The following comment accompanies the declaration of the SubSequence associated type in the Collection protocol:
>
> /// A sequence that represents a contiguous subrange of the collection's
> /// elements.
> ///
> /// This associated type appears as a requirement in the `Sequence`
> /// protocol, but it is restated here with stricter constraints. In a
> /// collection, the subsequence should also conform to `Collection`.
> associatedtype SubSequence : IndexableBase, Sequence = Slice<Self>
>
> The comments clearly state that the subsequence should conform to Collection, however, it is not declared as such. Why is this?
>
> Charles
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170213/e2a797f2/attachment.html>
More information about the swift-evolution
mailing list