Using angle brackets is not a must for supporting generics, but it is the 
common syntax of generics in programming languages that support generics, the 
same way as square brackets are the common syntax for indexing in programming 
languages.

If I understand correctly, the ambiguity problem with angle brackets appears 
only at instantiation, so if we prefixed all the angle brackets occurrences 
with a dot(.) that ambiguity would gone. 

Although prefixing the angle brackets with a dot(.) in all occurrences is not 
required and maybe removed from some places and/or be required only for 
instantiation. 

The common use for the dot(.) in programming languages is to access some field 
or property of the entity it's called on, and that would be the same(in 
instantiation case), cause we would be accessing the specific function, or the 
specific type of the generic function or the generic type, respectively, so 
that common understanding about the dot(.) would still hold, in my opinion. 

If I understand correctly(and please correct me if I am wrong) the dot(.) in 
that approach doesn't introduce any ambiguity and would require only one 
lookahead(to see if the following char is the left angle bracket or not), so it 
should be acceptable. 

example:

package list

type List.<E> struct {  // the dot(.) maybe remove here
// some code
}

type FloatList List.<float64>  // the dot(.) has to exist here

func NewList.<E>() (list List.<E>) {  // the dot(.) maybe remove here
// some code
}

func NewListFrom.<E>(arr []E) (list List.<E>) {  // the dot(.) maybe remove here
// some code
}

func(l List.<E>) Add(newElem E) {  // the dot(.) maybe remove here
// some code
}

package main

func main() {
        l := list.NewList.<int>()  // the dot(.) has to exist here
        l.Add(1)
        var arr []int
        intList := list.NewListFrom(arr) // type inference is done here, so the 
dot(.) doesn't exist here
}

-- 
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/0b206c05-e10c-48a4-b641-cb29209b9df5o%40googlegroups.com.

Reply via email to