Hi Rob,

This topic has been discussed many times on this list, so it's probably
best to look at and post in one of those threads. Let me take this chance
to collect as much information about this issue as I can in a single post.
Unfortunately, discoverability can sometimes be hard on mailing lists so I
don't blame you for not seeing all these.

Responses on the subject:
Design draft talking about alternative syntax:
https://go.googlesource.com/proposal/+/refs/heads/master/design/go2draft-type-parameters.md#why-not-use-the-syntax-like-c_and-java
Ian's justification for taking a wait-and-see approach to this syntax
issue: https://groups.google.com/g/golang-nuts/c/Rumm5HFhg_Q

Threads:
Use "<>": https://groups.google.com/g/golang-nuts/c/LvkOBA2D_Bk
Use "<>": https://groups.google.com/g/golang-nuts/c/B1Q1dsLa5rk
Use "::" and other suggestions:
https://groups.google.com/g/golang-nuts/c/b0GydCIn7T0
Use "(<>)": https://groups.google.com/g/golang-nuts/c/tYwWeiMztiI
Use "<>" before the name of the type being defined:
https://groups.google.com/g/golang-nuts/c/TJWGbrx2o34
Put type parameters in the regular arguments list with a ":type" suffix:
https://groups.google.com/g/golang-nuts/c/K7s-5MeXuzM
Use "<>", with some kind of additional syntax to make parsing easier:
https://groups.google.com/g/golang-nuts/c/SaDkSQdgF9g
Use "<>": https://groups.google.com/g/golang-nuts/c/coi7YS0KPgQ
Use "<>": https://groups.google.com/g/golang-nuts/c/ydySSqZqi-0
Use ":[]": https://groups.google.com/g/golang-nuts/c/zGQq_I5r2jg
No specific suggestion:
https://groups.google.com/g/golang-nuts/c/mY_36VU5ij8


On Sat, Jun 27, 2020, 05:38 Rob Reid <bass...@gmail.com> wrote:

> Hi team,
>
> I wanted to provide some feedback on the syntax used in the generics
> proposal.
>
> When I first opened the Go 2 playground, it took me a while to realise
> that (type T) was a generic parameter and not a function parameter and that
> (s []T) was a function parameter and not a return parameter):
>
> func Print*(type T)(s []T)* {
>     for _, v := range s {
>         fmt.Print(v)
>     }
> }
>
> I think this would start to look more confusing when there are return
> values (either single or multiple):
>
> func Something*(type T)(s []T) (T, T)*
>
> I think another character would server to improve the readability of the
> Print function in this example and hopefully prevent the time required to
> grok a generic function to someone who has not seen one in Go before:
>
> func Print*<type T>(s []T)* {
>     for _, v := range s {
>         fmt.Print(v)
>     }
> }
>
> func Print*[type T](s []T)* {
>     for _, v := range s {
>         fmt.Print(v)
>     }
> }
>
>
> Cheers,
>
> Rob
>
> --
> 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/CA%2Bcy9cUuJqOWWwi4m-MSp6gxKLGC4oFNn6y1zYJgN0Aac31sFg%40mail.gmail.com
> <https://groups.google.com/d/msgid/golang-nuts/CA%2Bcy9cUuJqOWWwi4m-MSp6gxKLGC4oFNn6y1zYJgN0Aac31sFg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAA%3DXfu2VxFv9DeBhpX1F6urHHTQLxka82P4JAZuQWuRQCsDfRA%40mail.gmail.com.

Reply via email to