Hacker News new | ask | show | jobs
by zeeboo 450 days ago
https://go.dev/doc/faq#generic_methods
2 comments

This is a good write-up of the issue. To see where this craziness could have led, see the C++ overload resolution logic, which isn't the exact same problem but does smell the same: https://en.cppreference.com/w/cpp/language/overload_resoluti...
I feel there's a clear alternative to the problem presented. I do not expect Empty to match any of those interfaces. A generic method should only match with a generic method of the same arity.
This has nothing to do with arity?
arity as in "number of generic arguments," I think they meant.
Still confused then, because there are two sets of generic arguments at play, and a proper call would match the arity of both.
Yeah, it would be that plus the name and the signature as per usual. I don't think this is a huge limitation considering the alternative they chose: disallow generic methods altogether.
So how would you implement generic method calls via an interface reference?