Personally () parentheses seems like to be harder to read, too similar with function calls.
It would be nicer if we use brackets instead [] like in Nim, since [] only used in array/slice/indexing (index key or empty), which is more readable than () that used in many ways (receiver, parameter, return value, function calls, grouping, etc). Current https://go2goplay.golang.org/p/zBO9K4-yXck package main import ( "fmt" ) type Stack(type T) struct { list []T } type Pair(type K, V) struct { Key K Val V } func New(type T)() Stack(T) { return Stack(T){list: []T{}} } func (s *Stack(T)) Push(v T) { s.list = append(s.list, v) } func main() { a := New(int)() fmt.Printf("%#v\n",a) b := Stack(Stack(int)){} fmt.Printf("%#v\n",b) c := Pair(string,int){} fmt.Printf("%#v\n",c) } Probably more readable syntax: - F:T for single generic declaration and usage, eg. Stack:int, BinaryTree:string, Vector:Person - F:[T1,T2] for multiple generic declaration and usage or when having constraint or array/slice, eg. Pair:[string,int], HashTable:[string,int], Stack:[T Stringer], Stack:[[3]int] - F:[T1:T2] for nested generic usage, eg. Stack:[Queue:int] So for example, if we want to use Stack that stores string-int Pair, we could use: Stack:[Pair:[string,int]], if we want to use Pair with string key and integer Stack value, we could use: Pair:[string,Stack:int] The pros: - we could always differentiate between function calls (that returns function) and generics by : or :[] symbol, other than just checking whether passed parameter is a datatype or variable/constant identifier. = unambiguous - consistent syntax between generic declaration and usage type Stack:T struct { list []T } type Pair:[K,V] struct { Key K Val V } func New:T() Stack:T { return Stack:T{list: []T{}} } func (s *Stack:T) Push(v T) { s.list = append(s.list, v) } func main() { a := New:int() fmt.Prinf("%#v\n",a) b := Stack:[Stack:int]{} fmt.Printf("%#v\n",b) c := Pair:[string,int]{} fmt.Printf("%#v\n",c) } -- 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/d0cd52bc-b33d-4256-83e3-40a0a24ddc3do%40googlegroups.com.