2 ms·
Grandparent 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 contai
by yencabulator 2y ago
Grandparent 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).