Why not try the design of Feel language,
There is no ambiguity and no more code.
```
type [Item T] struct {     
    Value T 
} 
func (it [Item T]) Print() {     
    println(it.Value) 
} 
func [TestGenerics T V]() {     
    var a = [Item T]{}     
    a.Print()     
    var b = [Item V]{}     
    b.Print()
 } 
func main() {    
     [TestGenerics int string]() 
}
```
On Thursday, July 16, 2020 at 3:16:51 PM UTC+8 Henrik Johansson wrote:

> This is good. I have been reaching for a consistency check and this just 
> may be it.
>
> On Thu, Jul 16, 2020 at 12:04 AM 'Dan Kortschak' via golang-nuts <
> golan...@googlegroups.com> wrote:
>
>> On Wed, 2020-07-15 at 14:36 -0700, Randall O'Reilly wrote:
>> > And the use of [ ] in map is more semantically associated with its
>> > conventional use as an element accessor in arrays / slices, not with
>> > some more general kind of type parameter.
>>
>> The [] syntax can be viewed as an indexing operation perfectly well in
>> the context of generics; a generic function or type is a map of
>> implementations or types and so the [] syntax is a type index into that
>> map, just as map[T1]T2 is a type index into the builtin generic map
>> type. This is not mental stretch.
>>
>>
>> -- 
>> 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/abe84ff5abefe2815137bea9cb83eb9e8d5fdafb.camel%40kortschak.io
>> .
>>
>

-- 
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/dda8c231-0390-4506-a82f-c051ba370942n%40googlegroups.com.

Reply via email to