On Wed, Oct 11, 2023 at 11:31 PM Torsten Bronger < bron...@physik.rwth-aachen.de> wrote:
> > 'Axel Wagner' via golang-nuts writes: > > > > > [...] > > > > > > What would this do? > > > > > > func F(s []any) { > > > s[0] = "Foo" > > > } > > > func main() { > > > s := []int{1,2,3,4} > > > F(s) > > > fmt.Println(s) > > > } > > > > I think most intuitive would be if this behaved as an implicit > > instantiation of the function with the type passed to it. > > Anyway, I mean > instantiation of F with a concrete type before the actual > compilation step. The same thing already happens if you write F[T > []E, E any](s T). > Here F is a simple, non-generic function, with no type parameters. It cannot be instantiated. Any attempt to explain what this code would do if it were legal (which it should not be) should not involve generics, type parameters, or instantiation. This is very different from what you would get by writing F[T []E, E any](s T) or F[E any](s []E); those are generic functions that can be instantiated. -- 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/CAADvV_t4c_a3GJpo%3DZhqofoEfBvJND7VHnBgbMcfW_4adJWt1w%40mail.gmail.com.