[generics]Use "<>" to declare template would be better than "()"

149 views
Skip to first unread message

hao luo

unread,
Jun 17, 2020, 12:36:09 PM6/17/20
to golan...@googlegroups.com
The creator:

Hi, I am extremely interested in and eager for golang's generics, and I have read the updated draft. https://go.googlesource.com/proposal/+/refs/heads/master/design/go2draft-type-parameters.md#acknowledgements

I think use "<>" to declare template's type would be more appropriate.

Original in the draft:

func Print(type T)(s []T) {
	// same as above
}

My opinions:

func Print<type T>(s []T) {
	// same as above
}

The reason:
1. More clear to discriminate and generics to normal funcs and type.
2. Use "<>" to declare type for generic code.
3. Use "()" to declare running params.

Wish you can give a thought to it.

hao

Denis Cheremisov

unread,
Jun 17, 2020, 12:50:40 PM6/17/20
to golang-nuts
Better for who? You? 
I would to love to see `[]` instead of `()`, but `<>` are horrible to read IMO.

среда, 17 июня 2020 г., 19:36:09 UTC+3 пользователь hao luo написал:

Ian Lance Taylor

unread,
Jun 17, 2020, 8:49:42 PM6/17/20
to hao luo, golang-nuts
Reply all
Reply to author
Forward
0 new messages