CTMacUser
(Daryle Walker)
1
Have a function that returns "some Sequence<MyElement>." The sequence type is also a lazy sequence, but "some LazySequenceProtocol<MyElement>" doesn't work. So:
- Transitivity is supposed to work, but there's a (major) problem with the compiler.
- Transitivity isn't supported, and the Swift team forgot to tag a primary associative type for
LazySequenceProtocol.
- The Swift team deliberately doesn't want to give
LazySequenceProtocol a primary type.
I can see transitivity not (initially?) being supported a valid decision, so I'm guessing the answer is #2. Unless someone can supply a reason why it's actually #3.
1 Like
I don't know the answer. I've just used composition to get around it so far.
some Sequence<MyElement> & LazySequenceProtocol
2 Likes
xwu
(Xiaodi Wu)
3
It's actually #3, because there was doubt about the right primary associated type, which would notably not have been Element.
The document no longer proposes primary associated types for LazySequenceProtocol and LazyCollectionProtocol. I still think Elements is the right choice for these, but this is mostly based on speculation rather than actual use cases. I would like to add these back, but I'd love to see some actual example cases to confirm/reject this choice.
6 Likes