* letting people being able to abuse them. C++ cough cough.
* making it clear to people reading the code what is happening.
I’ve noticed a few things:
* associated types in Rust are much clearer than generics
* one letter generics are “overly generic” and do not describe enough.
* the declaration of the type really adds verbosity
So what can a language do?
1. Maybe change the syntax to this one:
func eat(food []generic.Type)
Or func eat(food []g::type)
Or something that doesn’t involve adding more <> or ()2. Forbid one letter generic or force a description of the generic or even better: force listing all the types that are currently using this generic NEXT to the generic!
g.type -> {egg, bacon}
func eat(food []g.type)
But then you can’t use a generic from another package... but maybe it’s a good limitation?Or force a generic to have a description, which is what golang is doing with interfaces. The problem is that we can’t combine difference interfaces like in Rust/ocaml