[swift-evolution] Get a list of Concrete Implementers for Protocols
Jonathan Hull
jhull at gbis.com
Tue Oct 3 09:08:27 CDT 2017
Hi Evolution,
We talked a while back about being able to get a list of all concrete implementations for a protocol (i.e. all the types that adhere to it). Is this still being planned?
There are a couple of big use-cases for this:
• The first is for plug-ins and other things that require registration. A protocol can provide a way for them to be auto-registered by calling a static method from the protocol on each of them.
• The second is that you can build robust + extensible factories.
I definitely have use for this right now. I am currently writing a UI generator that auto-generates functioning UI based on a given set of criteria/data. Right now, I have to manually register each partial-template (of which there will eventually be several thousand) with the factory by hand, which is an error-prone process. It is one of those things that was doable in ObjC pretty easily, but I still haven’t figured out how to do it in Swift.
Thanks,
Jon
More information about the swift-evolution
mailing list