Comment

Comment by foldr

I think this is mistaken. Go already has a way to represent 'open' union types (interfaces), so all of these runtime problems have already been solved. What's missing is just the type system support to do exhaustive matching on the members of the union. With the addition of generics, 'all' that would be necessary is to make the following a legal variable definition:

    var foo interface {
        struct { A int } | struct { B string }
    }
It currently fails with the following error:

"cannot use type interface{struct{A int} | struct{B string}} outside a type constraint: interface contains type constraints"

parent foldr 1 year ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton