On Tue, Jul 14, 2020 at 10:06 PM Paul Johnston <pcj...@gmail.com> wrote:
>
> If the generic expression <T> was always attached/constrained to the "type" 
> or "func" keyword (rather than the type or function name), perhaps this would 
> decrease the lookahead problems with lexing?  For example:
>
> type<T> Point struct {
>     x, y int
>     data T
> }
>
> type<R,S> Transformer interface {
>     Transform(R) S
> }
>
> func<T> Stringify(s []T) string {
> }
>
> type<T> Vector []T

Well, you need to consider not just the definitions, but also the uses.

The suggested syntax, whether with parentheses or square brackets, has
what I consider to be a very nice property: the definition and use
syntaxes are very similar.  For the definition we write

func F[type T]() {}

For the use we write

F[int]()

The two aren't identical, but the syntax is parallel.

The same is true in Java.  Admittedly in C++ the syntaxes are not
parallel, and are more like what you suggest.

Ian

-- 
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/CAOyqgcXQRpYJw%3DO%3DFp-jSJrUrD08A1FYwMBUE1OVc4yskyud6g%40mail.gmail.com.

Reply via email to