[generics] (<T>) instead of (type T)

236 views
Skip to first unread message

cny...@gmail.com

unread,
Jun 20, 2020, 1:34:04 PM6/20/20
to golang-nuts
Hi,

The type parameters in the current proposal uses `(type xxx)` which is visually hard to distinguish from function parameters.

There are reasons stated in the proposal to not adopt <> (which is common in other languages) which I'm not going to challenge. But have you considered `(<T>)`? It should eliminate the infinite lookahead concern of using <>, require minimal change to the existing implementation in go2go, and IMO improves the readability of Go code w/ generics.

David Anderson

unread,
Jun 20, 2020, 1:45:39 PM6/20/20
to cny...@gmail.com, golang-nuts
It's covered in the generics design doc, and by about a dozen threads on golang-nuts at this point. Unless the parsing issues can be addressed satisfactorily, that option is off the table right now. Same for [T] and other variations.

- Dave

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/8c23b598-5b67-4ca3-a736-ea18fa4060e8o%40googlegroups.com.

Nigel Tao

unread,
Jun 22, 2020, 10:46:54 AM6/22/20
to David Anderson, cny...@gmail.com, golang-nuts
On Sun, Jun 21, 2020 at 3:45 AM David Anderson <da...@natulte.net> wrote:
> It's covered in the generics design doc, and by about a dozen threads on golang-nuts at this point.

I think that the suggestion was for F(<T>), not F<T>. If so, that
suggestion isn't covered by the generics design doc or the other
golang-nuts threads.

Ian Lance Taylor

unread,
Jun 25, 2020, 9:02:48 PM6/25/20
to cny...@gmail.com, golang-nuts
On Sat, Jun 20, 2020 at 10:33 AM <cny...@gmail.com> wrote:
>
> The type parameters in the current proposal uses `(type xxx)` which is visually hard to distinguish from function parameters.
>
> There are reasons stated in the proposal to not adopt <> (which is common in other languages) which I'm not going to challenge. But have you considered `(<T>)`? It should eliminate the infinite lookahead concern of using <>, require minimal change to the existing implementation in go2go, and IMO improves the readability of Go code w/ generics.

Let's see what real code looks like with the suggested syntax, before
we worry about alternatives. Thanks.

Ian
Reply all
Reply to author
Forward
0 new messages