Is there any documentation regarding the choice of associatedtype
and the related typealias
over using generics syntax in protocols?
I was recently interested in building some container types backed by a class/struct cluster and was disappointed to see that the current state of the art is to create a dummy parent class with methods stubbed with fatalErrors
. This eliminates any compile time checks for subclass implementations that must override every method from the parent or fail at runtime if one is missed. Obviously unit testing and coverage helps here, but having the compiler as a first line of failure would be helpful.
Is there something that associated
types can do that generic constraints cannot?
I know that protocols are not "first class" types and value types may make using them more complicated than in reference-type only languages, but it would be really nice to be able to build class clusters without resorting to hacks.