If I understand correctly, having a simple protocol (aka no associated types):
protocol Person {
var name: String { get }
}
allows the usage of the Person
type (does such a type have a name?) without any effort. Is this because the size of the type can be calculated by the compiler?
However, introducing associatedtpye
to the equation suddenly causes problems:
protocol Person {
associatedtype JustaTypeName
var name: String { get }
}
(does a type Person
have a different name now? )
Now, suddenly variables need to be declared as any
or some
or generics must be used.
Is this because now the type's size cannot be know at compile-time?