[swift-evolution] [Completing Generics] Arbitrary requirements in protocols

Jacob Bandes-Storch jtbandes at gmail.com
Mon Apr 11 16:36:48 CDT 2016


On Mon, Apr 11, 2016 at 11:56 AM, Dave Abrahams via swift-evolution <
swift-evolution at swift.org> wrote:

>
> on Mon Apr 11 2016, Jacob Bandes-Storch <swift-evolution at swift.org> wrote:
>
> > Doug wrote this in the Completing Generics manifesto, under "Minor
> extensions":
> >
> >     *Arbitrary requirements in protocols
> >
> >     Currently, a new protocol can inherit from other protocols,
> introduce new
> >     associated types, and add new conformance constraints to associated
> types
> >     (by redeclaring an associated type from an inherited protocol).
> However, one
> >     cannot express more general constraints. Building on the example from
> >     “Recursive protocol constraints”, we really want the element type of
> a
> >     Sequence’s SubSequence to be the same as the element type of the
> Sequence,
> >     e.g.,
> >
> >     protocol Sequence {
> >     associatedtype Iterator : IteratorProtocol
> >     …
> >     associatedtype SubSequence : Sequence where
> SubSequence.Iterator.Element ==
> >     Iterator.Element
> >     }
> >
> > +1.
> >
> > To make it into Swift 3, would this feature require a proposal of its
> > own?
>
> It could be part of another proposal, but it should be in a proposal.
> Whether or not it can still make Swift 3, I am unsure.
>
> > How feasible would it be to implement on top of the current system?
>
> I can't answer that, but if you want to work on this I'd suggest
> starting with the implementation.  In this case, the proposal is the
> easy part.
>

I was mostly wondering if anyone inside the team has already thought about
how to do this, or perhaps even started working on it. If it's in the
pipeline, it might affect our discussion about "allValues" for enums (which
I'm going to send an email about soon).


>
> --
> Dave
>
> _______________________________________________
> 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/20160411/3c48a21a/attachment.html>


More information about the swift-evolution mailing list