3 ms·
Yes, that's true. But that means the problem is solved, no? I think my previous comment was badly worded. I just meant to say that Go has a concurrent GC and a
by foldr 2y ago
Yes, that's true. But that means the problem is solved, no? I think my previous comment was badly worded. I just meant to say that Go has a concurrent GC and a runtime representation of a value that can instantiate one of a number of different types (i.e. interface values). So as long as one is willing to accept that as an implementation for an enum/union type, all of the major runtime problems are already solved.
- yencabulator 2y agoGrandparent tried to argue that the mere existence of a tag tells GC what to do, when that's racy. If you avoid the race, forcing sum types to only ever contain a single pointer, sure that avoids the race too. It still doesn't get you a meaningful zero value, which the language design assumes to exist for every type.
- foldr 2y agoSure, I appreciate that concurrent GCs are hard. For interfaces, the Go team chose one of a number of possible solutions: https://github.com/golang/go/issues/8405 https://github.com/golang/go/issues/8405 If the language were to add support for union types, these tradeoffs could potentially be revisited. Other commentators have pointed out that nil is a perfectly good default value for a union (if it's underlyingly an interface).