by foldr · 1y ago · 0 comments
In cases where there is a lot of variance in the size of the different interface implementations, separate allocations could actually be more memory efficient than a tagged union. In any case, I'm not sure that memory efficiency is the main reason that people miss Rust-style enums in Go.
I agree with you about the overall motivation for Rust-style enums. I just think it's surprisingly complex to get even the memory efficiency advantages, never mind anything more ambitious.
The solution to this should be trivial. You just have to extend the gcshape concept to account for the enum discriminator.
I'm not sure what you're referring to with 'anything more ambitious'.