[generics] type lists in interfaces

130 views
Skip to first unread message

武新飞

unread,
Nov 12, 2020, 8:15:16 AM11/12/20
to golang-nuts, gri
Here is my suggestion to replace "Type lists in interfaces"
```
type Float interface {
    type float32, float64
}
 ```
Can be
```
type Float = float32 | float64

type Ordered = int | int32 | ... Float | string
```

Ian Lance Taylor

unread,
Nov 12, 2020, 9:10:05 AM11/12/20
to 武新飞, golang-nuts, gri
Thanks for the note.

In the current design draft the section
https://go.googlesource.com/proposal/+/refs/heads/master/design/go2draft-type-parameters.md#constraint-type-inference
describes a case where we need both a type list and a method. I don't
see an obvious way to implement that with your suggested syntax.

Ian
Reply all
Reply to author
Forward
0 new messages