Are you trying to make user-defined generic maps look more like built-in 
ones?

map[T1]T2  is hard-coded syntax in go. But so is m[k] for accessing 
elements - and you can't use that in user-defined types anyway.

Therefore I don't think it helps much to be able to write mymap[T1]T2 
instead of mymap[T1, T2], because you can't use the corresponding 
accessors.  You would need something like:

func (m *MyMap[KT, VT]) set(k KT, v VT) ...
func (m *MyMap[KT, VT]) get(k KT) VT ...

Also: to create one of these objects there is more built-in syntax you 
can't use:
    v := make(mymap[T1]T2)   // won't work

so you need to use a factory function. With your proposed syntax it would 
be:
    v := makemymap[T1]T2()

which IMO is worse than
    v := makemymap[T1, T2]()

Example code: https://go2goplay.golang.org/p/2i3dgP2cKyz

-- 
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/07d8b489-9ad3-4779-8adf-2733afa77196n%40googlegroups.com.

Reply via email to