3 ms·
The article says the garbage collector can't know which variant the union type is. I don't know how to interpret that other than an (incorrect) assumption of un
by adastra22 2y ago
The article says the garbage collector can't know which variant the union type is. I don't know how to interpret that other than an (incorrect) assumption of untagged unions.
- IshKebab 2y agoIt is written a little confusingly but that's not what they're saying. They were saying you can't implement a union in user code with the current garbage collector because there's no way to tell it which variant your union is: > let's ask why we can't implement such a union type today using Go's unsafe package to perform suitable manipulation of a suitable memory region. They are aware that you could add union types to Go - their point is that it would require garbage collector modifications which may be difficult: > The corollary to all of this is that adding union types to Go as a language feature wouldn't be merely a modest change in the compiler. It would also require a bunch of work in how such types interact with garbage collection, Go's memory allocation systems (which in the normal Go toolchain allocate things with pointers into separate memory arenas than things without them), and likely other places in the runtime.