News for hackers. Stuff that matters.
Re:The Next Step for Generics by ookdatnog on Wednesday June 17, 2020 @07:35AM (#23550201)
There is an underappreciated advantage to using generics in function signatures: they inform you about exactly which properties of your type a function is going to ignore (this is called parametricity: https://en.wikipedia.org/wiki/Parametricity)

For instance, if you have a function `f : Vec<a> -> SomeType`, the fact that `a` is a type variable and not a concrete type gives you a lot of information about `f` for free: namely that it will not use any properties of the type `a`, it cannot inspect values of that type at all. So essentially you already know, without even glancing at the implementation, that `f` can only inspect the structure of the vector, not its contents.

Re:The Next Step for Generics by steveklabnik on Wednesday June 17, 2020 @09:28AM (#23551099)
Not all generics are parametric.
Re:The Next Step for Generics by ookdatnog on Wednesday June 17, 2020 @10:04AM (#23551513)
Agreed. From a quick skim of the Go generics proposal I get the impression that they are in fact aiming for parametric generics though (in fact they use the term "parametric polymorphism" in the background section).