[swift-evolution] [Review] Constraining AnySequence.init

Max Moiseev moiseev at apple.com
Fri Dec 18 19:05:04 CST 2015

Thanks for a review Kevin!

> At the moment AnyCollection does not delegate calls to SequenceType protocol methods to the underlying base sequence
> Presumably that should say AnySequence instead of AnyCollection, since the rest of the proposal talks about AnySequence?
Good catch. Although applicable to AnyCollection as well, this should mention AnySequence in this case. 👍

> 2. One of the added constraints looks like
> S.SubSequence.SubSequence == S.SubSequence
> with a comment saying that ideally the set of constraints would apply to the SequenceType protocol but that's not currently possible. This makes sense for the other constraints (that SubSequence conforms to SequenceType and has the same element), but this particular constraint, that the subsequence type must have itself as its own subsequence, surprises me a little. I can see why it's needed here (because that's the only way you can guarantee that recursing through SubSequences always finds SequenceTypes with the right element), but ideally we wouldn't actually require it to be the _same_ sequence, just that it is some sequence with the same element type. If we ever change Swift such that these constraints can be expressed on the SequenceType definition itself, then presumably we'll be able to drop this == constraint entirely as the SequenceType protocol itself will ensure that its subsequence is a sequence of the same element type (which will satisfy the need to have it be true after arbitrary levels of recursion).

You’re totally right again. I will make these changes to the proposal.


[a bunch of text removed]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151218/26a20386/attachment.html>

More information about the swift-evolution mailing list