I think this proposal looks pretty good, but it does expose something odd about the core language. Given this example from the article:
func Max(type T ordered) (a, b T) T {
if a < b {
return b
}
return a
}
It would make me assume that if I were to write a function that looks like this, it would at least accept the same type of arguments: func AnotherFunction(a, b ordered) {
...
}
As in, substituting 'T' with 'ordered'. Unfortunately, it would not. In this case, the arguments are interface objects, which are pointers under the hood. Calls to the function have to be adjusted to pass in pointers. I think Go would have been more consistent if instances of interface objects always had to be prefixed by * . Concretely, this would throw a compiler error: func ReadStuff(r io.Reader) {
...
}
Instead, it should be written as follows: func ReadStuff(r *io.Reader) {
...
}
As in, r is a pointer to an object that implements the io.Reader interface.