On Fri, Nov 12, 2021 at 6:20 PM tapi...@gmail.com <tapir....@gmail.com> wrote:
> How much complicated? Is it similar to > > func foo(int int) {} > No. As I said, the situation is different, as type-parameters must be able to be self- and mutually referential. > > >> >> >>> >>> >>>> >>>> or basically any use-case for constraint-type inference. >>>> >>>> Even if we *could* allow it consistently, the rules for doing that >>>> would likely be pretty complex. Better to take the relatively minor hit of >>>> disallowing this overloading (you can always use different names for the >>>> type-parameters, if they conflict with the constraint you want to use) than >>>> to take the hit of complex scoping rules with lots of exceptions. >>>> >>>> On Fri, Nov 12, 2021 at 9:48 AM tapi...@gmail.com <tapi...@gmail.com> >>>> wrote: >>>> >>>>> I expect the following code compilers okay, but it doesn't. >>>>> It looks All the three "I" in the Bar function declaration are >>>>> viewed as the type parameter, whereas the second one is >>>>> expected as the constraint I (at least by me). >>>>> >>>>> package main >>>>> >>>>> type I interface { M() } >>>>> >>>>> func Foo(i I) { >>>>> i.M() >>>>> } >>>>> >>>>> func Bar[I I](i I) { // cannot use a type parameter as constraint >>>>> i.M() >>>>> } >>>>> >>>>> func main() {} >>>>> >>>>> -- >>>>> 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...@googlegroups.com. >>>>> To view this discussion on the web visit >>>>> https://groups.google.com/d/msgid/golang-nuts/9fc66e8e-3f99-4c3a-87f7-ce7c1a705cdcn%40googlegroups.com >>>>> <https://groups.google.com/d/msgid/golang-nuts/9fc66e8e-3f99-4c3a-87f7-ce7c1a705cdcn%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...@googlegroups.com. >>> >> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/golang-nuts/a4ffdc09-02cf-47af-96fc-3ebde3fc5d10n%40googlegroups.com >>> <https://groups.google.com/d/msgid/golang-nuts/a4ffdc09-02cf-47af-96fc-3ebde3fc5d10n%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/3d4fc243-f3dc-4071-b6ac-8c5462061e3en%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/3d4fc243-f3dc-4071-b6ac-8c5462061e3en%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/CAEkBMfEe_DQsaxjuk3ES2Px9q8H6zAxAHnUVejuyefnbxWMHFw%40mail.gmail.com.