2 ms·
> the exorbitant privilege of being parameterized by a type This is how built in collection types work in pretty much all statically typed languages. For exam
by foldr 4y ago
> the exorbitant privilege of being parameterized by a type
This is how built in collection types work in pretty much all statically typed languages. For example, here is an array of ints in C:
int foo[] = { 1, 2, 3 };
We wouldn't usually say that C has 'generic arrays'.
> any new type created by a mere programmer has to be monomorphic.
Collections in (pre-Generics) Go are monomorphic. []foo and []bar are as different as foo and bar. That is why, for example, the first argument of sort.Slice has type 'any' (https://cs.opensource.google/go/go/+/go1.18.2:src/sort/slice.go;l=16 https://cs.opensource.google/go/go/+/go1.18.2:src/sort/slice...)