DEV Community

Discussion on: Go 2 Draft: Generics

Collapse
 
dean profile image
dean

The idea behind their parentheses are that it should act like a function - calling Max(int32) returns a func(int32, int32) int32. To call this function, one could do Max(int32)(x, y), or with type inference, Max(x, y) will work fine.

Then to declare a function that takes type parameters, it should ideally look similar to calling it: func Max(type T)(i1, i2 T) T.

That is the justification for all of the parentheses. I'm not sure if I entirely agree with it, but I'm not against it.