5 ms·
https://go.dev/doc/faq#generic_methods https://go.dev/doc/faq#generic_methods
by zeeboo 2y ago
https://go.dev/doc/faq#generic_methods https://go.dev/doc/faq#generic_methods
- singron 2y agoThis 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_resolution https://en.cppreference.com/w/cpp/language/overload_resoluti...
- wseqyrku 2y agoI 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.
- int_19h 2y agoThis has nothing to do with arity?
- remexre 2y agoarity as in "number of generic arguments," I think they meant.
- int_19h 2y agoStill confused then, because there are two sets of generic arguments at play, and a proper call would match the arity of both.
- wseqyrku 2y agoYeah, 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.
- int_19h 2y agoSo how would you implement generic method calls via an interface reference?
- VirusNewbie 2y agoThe same way the other languages do it.
- remexre 2y agoIsn't that way either JIT or boxed integers?