On Tue, Mar 23, 2021 at 2:17 PM atd...@gmail.com <atd...@gmail.com> wrote: > > Quick question... > > Why do we need brackets to define a parametered function, struct etc...? > > Why not change Go kinds to accept either a type (would produce a regular, > function, structs, etc) or a new type parameter object that would implement > the constraints (would produce a generic function definition) > > for instance, > > type parameter T > > // [...] some way to add constraint to T > > func Max(v T) T{...} > > What are the brackets for? Just an idea.
Each call to Max can use a different value for T. We can call Max[int] and Max[string]. How would we do that with this notation? A type parameter really is a parameter to the function. Making it syntactically similar to other non-type parameters seems like a good idea to me. 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcVLgSXG6X1PJqDjy%3D%3DiTjx_y9merLmZfW67qtggnd0sgw%40mail.gmail.com.