3 ms·
I agree that one cannot simply hand wave a language feature into existence. What I don't understand is why you consider a requirement to change the runtime to d
by noelwelsh 2y ago
I agree that one cannot simply hand wave a language feature into existence. What I don't understand is why you consider a requirement to change the runtime to disqualify a new feature.
In this case, if I understand your complaint correctly, what you are saying is there is a race condition between setting the tag of a variant / union / sum type and the GC reading that tag to interpret the memory layout. I agree this is an issue, but it's an issue with any memory write. This is why garbage collectors have a write barrier, and the Go GC is no different (e.g. [1]). So ultimately I don't see the problem as unsurmountable. Yes, it will require some thought and some runtime changes, but the foundation (i.e. type tags, the write barrier) is already in place.
[1]: https://ihagopian.com/posts/write-barriers-in-the-go-garbage-collector https://ihagopian.com/posts/write-barriers-in-the-go-garbage...