On Thu, Jan 6, 2022 at 7:02 PM Brian Candler <b.cand...@pobox.com> wrote:
> On Thursday, 6 January 2022 at 17:13:38 UTC axel.wa...@googlemail.com > wrote: > >> On Thu, Jan 6, 2022 at 1:58 PM tapi...@gmail.com <tapi...@gmail.com> >> wrote: >> >>> I don't think your conclusion is right. Otherwise, the following code >>> doesn't compile, but it does. >>> >>> type C interface{ int; any } >>> >>> func f[T C](x byte) T { >>> return T(x) >>> } >>> >> >> I agree that the compiler and spec seem to disagree here. It seems to me >> that by the spec, this should not be allowed, as C has no specific types. >> > > But is that true? "Type set" and "specific types" are two different > concepts, and "specific types" are only required in certain contexts, which > are called out in the spec. > Correct. One of those is determining if the conversion `T(x)` is legal, if `T` is a type parameter. Specifically, it only makes it legal if `T` is a type parameter with specific types. It seems that function f[T C] will accept any type which is in the *type > set* of C - is that not reasonable? > Yes. But the issue isn't the instantiation of `f` (in fact, `f` is not instantiated in this code), it's the definition. > > This does of course highlight how complex the language has become with the > introduction of generics. > > -- > 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. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/6edaaaf6-87a8-4cb4-9015-8bb007a5d70cn%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/6edaaaf6-87a8-4cb4-9015-8bb007a5d70cn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAEkBMfE11SwkehK4geQiRBY4A-2wnbkMRJy_Wj7_AgFb2jyYvQ%40mail.gmail.com.