[Pitch] Use “some” to express “some specialization of a generic type”

An existential type any P & Q is really something like this, we’re that syntax to exist: any <T where T: P, T: Q> T; that is, it’s a container for a value of type T which is a generic parameter in a local generic signature with some requirements imposed on it. Similarly any Sequence<Int> becomes any <T where T: Sequence, T.Element == Int> T.

Your any Array would become any <T> Array<T> in the more general syntax; so it’s a container storing an Array<T> (not just T) and the T is type erased. You could also have more than one erased parameter, for eg any Dictionary.

Not sure we’ll ever get “fully generalized existentials” in the surface language, but this is fact how they’re modeled internally in the compiler.

(If I ever get around to finishing it, Part II of Compiling Swift generics has a chapter on existential types).

9 Likes