On Tue, Jun 16, 2020 at 8:12 PM Brandon Dyck <bran...@dyck.us> wrote: > > I find it a little strange that an interface with a type list can only be > used as a constraint, and not as the type of a variable or parameter, despite > it using basically the same syntax as a normal interface. Is this difference > between constraints and other interfaces a property of the type system, or > just a limitation of the translation? I don't think it was explicit in the > design document. It would certainly be useful to declare variables with > type-list interfaces, as it would provide a much less hacky way to define sum > types than using an unexported interface method as in > https://medium.com/@haya14busa/sum-union-variant-type-in-go-and-static-check-tool-of-switch-case-handling-3bfc61618b1e. > > My failing example is at https://go2goplay.golang.org/p/-lQ0jKs8_hU.
We mention this briefly at https://go.googlesource.com/proposal/+/refs/heads/master/design/go2draft-type-parameters.md#type-lists-in-interface-types . Ian -- 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/CAOyqgcX1DS4w4-QbvdqRXGpEKZFJPXCMtM27BK9WiPgbcFg18g%40mail.gmail.com.