by bigdubs · 2y ago · 0 comments
[1] https://go.googlesource.com/proposal/+/refs/heads/master/des...
I've been using Go as my primary language for a decade, and the lack of generics on methods was surprising to me the first time I ran into it, and the reasoning not obvious.
There's no theoretical reason not to have it, the reason is because of a random intersection of other design decisions... unless you're saying they made those choices fully expecting to have these restrictions on generics later?
What? Methods are not needed if not for implementing an interface?
Anyway, functions could also be implementing interfaces, some languages allow that.
I swear the go docs read like a cult.
And unless you're also using interfaces, methods are no different from functions aside from call syntax.
Methods bind state with a function.
That an object can satisfy an interface is secondary here. In different languages, an interface could be satisfied with a combination of methods, fields, or nominality.
If the statement "we could decide that parameterized methods do not, in fact, implement interfaces, but then it's much less clear why we need methods at all" was true, then there should not be a single struct in go (stdlib nor elsewhere) that does not implement some interface (and it must be used via that interface to make sense). This is obviously not the case.