On Wed, 12 Aug 2020 at 16:43, 李晓辉 <lixiaohui0...@gmail.com> wrote:

> Maybe `type list` equals to `sum type`
>
> type SignedInteger interface {
>        type int, int8, int16, int32, int64
> }
>
> can replaced by
>
> type SignedInteger int|int8|int16|int32|int64
>

Yes, I've had that thought too (and mentioned it as feedback), but there's
one wrinkle: what about the "underlying type" behaviour of generics?
That is, although matching on the underlying type instead of the actual
type is useful for type parameters, it's less intuitive and/or useful
when used as a normal type. I think I'd be surprised if a value of type
"int|uint" was not exactly one of those two types.

For the record, I've made a somewhat detailed suggestion for sum types
along these lines here
<https://github.com/golang/go/issues/19412#issuecomment-288485048>.

  cheers,
    rog.

-- 
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/CAJhgacj7sQxzCeG26B9ShiirxtEQ7x%2BPSoUVBJ2rUr259m%2BT4Q%40mail.gmail.com.

Reply via email to