3 ms·
"The biggest reason is that you cannot write `var someVariable: SomeGenericType<Type>` nor use it as a parameter or a return in a protocol, for example." What'
by culturedsystems 9y ago
"The biggest reason is that you cannot write `var someVariable: SomeGenericType<Type>` nor use it as a parameter or a return in a protocol, for example."
What's the reason for that? In Java, for example, interfaces can be generic in just the same way concrete types can, which also means you can declare variables and parameters of some specific instantiation of the interface. It looks like Swift has two different generics systems, one for concrete types and one for protocols, leading to this extra complexity. Presumably there's some reason for doing things this way.
- mikeash 9y agoAs with many deficiencies in Swift, the reason is just that it takes time and effort to make it happen and it hasn’t been done yet.