3 ms·
Everything You Wanted to Know About Type Inference – and a Little Bit More
- valyala 3y agoGo lost its simplicity and became yet another mediocre programming language after adding generics :( All these non-trivial type inference rules are needed only for serving useless generics in Go. And these rules do not cover many edge cases yet, so they will become more complex over time.
- vimax 3y agoAll discussions of generic types seem to end at recursive types “type T[P T[P]]”. I don’t know if Go has an equivalent “super” operator, but in Java you can define: class Type<T extends Type<? super T>> Which puts an upper and lower bound on T. It has some interesting behavior with inheritance but I haven’t found it discussed anywhere.