[swift-evolution] [Discussion] Generic protocols
Karl Wagner
razielim at gmail.com
Fri Dec 2 13:10:47 CST 2016
Your problem is that you want to conform to the same protocol twice.
I've discussed ideas for how to support something like that. I'm not sure if it fits the core team's direction for swift.
Karl
>
> On Dec 2, 2016 at 7:34 pm, <Adrian Zubarev via swift-evolution (mailto:swift-evolution at swift.org)> wrote:
>
>
>
>
>
> I just overlooked that the subsection about generic protocols was inside the Unlikely section.
>
>
>
> The problem is that I need a way to refer to a function with a specific name. Plus the connection type has to have a specific API, like having a DispatchQueue and know the router object if there is any (sounds like a protocol right?!). The function reference should also keep the connection object alive with a strong reference.
>
>
>
> associatedtype does not solve that problem for me.
>
>
>
> I clearly see that generic protocols overlap with associatedtype but couldn’t we find a compromise here? For instance like Chris Lattner introduced generic type aliases without the ability of constants.
>
>
>
>
>
>
>
>
>
>
>
>
> --
> Adrian Zubarev
> Sent with Airmail
>
>
> Am 2. Dezember 2016 um 18:41:15, Tino Heth (2th at gmx.de (mailto:2th at gmx.de)) schrieb:
>
>
> >
> >
> >
> >
> >
> >
> >
> > >
> > > Aren't protocols generic already using associatedtype?
> > > Not really:
> > Take a look at (for example) AnyIterator… this whole layer of indirection could be removed with the requested change.
> >
> > You can declare a protocol that generates Ints, Strings or whatever you like — just not in a generic way, and that's a pity.
> >
> >
> >
>
>
>
>
>
>
>
> _______________________________________________ swift-evolution mailing list swift-evolution at swift.org (mailto: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/20161202/9d6a85e5/attachment.html>
More information about the swift-evolution
mailing list