[swift-evolution] [Discussion] Generic protocols

Martin Waitz tali at admingilde.org
Tue Dec 6 11:33:03 CST 2016


Am 2016-12-06 15:39, schrieb Daniel Leping:
> Does not this make associatedtype redundant additional complexity?

No, they serve a different use case.

Generic Type Parameters are used to create a new type from a 
parameterized template.
The user always has to be explicit about these parameters.

Associated types are used to create one protocol with constraints (where 
the protocol allows for some controlled variability in the conforming 
class/struct).
Here the associated types are inferred from the conforming type 
automatically.

-- 
Martin


More information about the swift-evolution mailing list