Yes, adding methods to instantiated generic types would have some similarities to (partial) template specialization in C++.
Having concluded that it was a bad idea anyway from the earlier discussion, I'm glad it's not going to be allowed :) On Tuesday, September 11, 2018 at 6:45:29 PM UTC+1, Ian Lance Taylor wrote: > > On Tue, Sep 11, 2018 at 10:04 AM, roger peppe <rogp...@gmail.com > <javascript:>> wrote: > >> func (x Foo(int)) Bar() {} > > > > As I understand it, this would be technically allowed, but would not > > mean what you think. > > > > This is defining a method Bar on the Foo type, and "int" is declaring > > a name for the type parameter defined in the definition of Foo. That > > name would shadow the global language built-in int type name, in the > > same way that it's currently valid in Go to do this > > (https://play.golang.org/p/fMwGrRnJEOt): > > > > type int otherType > > > > I don't see any ambiguity here. > > Yes. > > I think this general topic is what C++ calls template specialization. > The design draft explicitly does not support specialization. This is > listed in the "Omissions" section. Specialization is a step toward > template metaprogramming, which is a direction that I personally think > Go should avoid. > > Ian > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.