I'm not sure whether this: type Foo(type T) struct{}
would be allowed or not - the compiler might say "type parameter T is not used". Anyway, if it were allowed, then it would follow that these should also be allowed: func f(x Foo(int)) {} func (x Foo(int)) Bar() {} and that Foo(int) would implement Barrable but Foo(float64) would not. My understanding of the draft design is that the following wouldn't be allowed unless V were a 'concrete' type: func (x Foo([]V)) Bar() {} So you'd need to write something like this for it to compile: type V int // or whatever Alan On Monday, September 10, 2018 at 9:02:40 PM UTC+1, Patrick Smith wrote: > > Under the generics draft, would this be allowed? > > type Foo(type T) struct{} > > func f(x Foo(int)) {} > > > I assume the answer is yes; I can't see any good reason to disallow it. > > What about this? > > func (x Foo(int)) Bar() {} > > > If this is allowed, does this now mean that Foo(int) implements > > type Barrable interface { > > Bar() > > } > > > but that Foo(float64) does not implement Barrable? > > What about this, where V is meant to be a type parameter, not a specific > type that was defined earlier in the code? (If allowed, it probably needs a > 'type V' in it somewhere, but I'm not sure where to put that.) > > func (x Foo([]V)) Bar() {} > > -- 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.