2 ms·
> This has no safety benefit, since generics are resolved at compile time and all safety tests can be made after generic expansion. The compiler can verify tha
by Nullabillity 6y ago
> This has no safety benefit, since generics are resolved at compile time and all safety tests can be made after generic expansion.
The compiler can verify that types are satisfied. It cannot verify that you agree on what those types and operations mean.
For example, `Iterator` isn't very useful without being able to agree on what `Iterator::next`'s `Option` means. So implicit structural traits á la Go is somewhere between useless and actively harmful.
You can have nominal traits while allowing orphan instances (that is, implementations of foreign traits on foreign types). Scala and Haskell both have that. But IMO neither has a good solution for the conflicts that inevitably arise in that case.