The Go spec says:

A partial type argument list specifies a prefix of the full list of type 
arguments, leaving the remaining arguments to be inferred. Loosely 
speaking, type arguments may be omitted from "right to left" (Source 
<https://tip.golang.org/ref/spec#Instantiations>).

This means it is legal:

*type  E[T1, T2 any]  struct{ … }*
*T[]*
*T[int]*
*T[int, int]*

And this is not legal:

*T[_, int]*
*T[, int]*

I'm wondering which is the reasoning behind this restriction. Is it a 
limitation of the current implementation? Is it a design limitation? Is it 
just that nobody asked for it?

I'm posting this question because I've seen several colleagues (and myself) 
trying to use partial type lists which do not follow the "type arguments 
can be omitted from right to left" rule, and the first impression when you 
see the compiler yielding "syntax error: unexpected comma, expecting 
expression" is at least confusing. 

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/a1442dce-b530-47b2-9462-5c1a86ad6be6n%40googlegroups.com.

Reply via email to