[swift-evolution] Partially Constrained Protocols [Was: [Proposal] Separate protocols and interfaces]
David Waite
david at alkaline-solutions.com
Tue Jan 19 19:23:41 CST 2016
> On Jan 19, 2016, at 3:45 PM, Douglas Gregor <dgregor at apple.com> wrote:
>
>
>> On Jan 19, 2016, at 12:54 PM, David Waite <david at alkaline-solutions.com> wrote:
>>
>>
>>> On Jan 19, 2016, at 1:21 PM, Douglas Gregor <dgregor at apple.com> wrote:
>>>
>>> Right. There’s also SubSequence, which you almost certainly don’t want to have to specify. For reference, once we get generic typealiases, one would be free to add
>>
>> Yes, although in the version of SequenceType which declared earlier in the thread, there was no longer a need for SubSequence, as I could just return protocol<SequenceType where .Element == Element> where needed.
>
> I suspect that there is a class of algorithms for which it is interesting to limit ourselves to “SubSequence == Self”, which one would lose by making SubSequence an existential.
>
> - Doug
So something like the following?
protocol SequenceType {
associatedtype Element
associatedtype SubSequence:protocol<SequenceType where .Element == Element>
…
}
extension SequenceType where SubSequence == Self {
…
}
-DW
More information about the swift-evolution
mailing list