4 ms·
What is the reason for using product of all primitive types for boxing instead of tagged union?
by karavelov 12y ago
What is the reason for using product of all primitive types for boxing instead of tagged union?
- artagnon 12y agoBecause one type may use more than one field. Vectors and strings use the nr field additionally, and functions use the vector/fenv field additionally. Instead of creating a hierarchy, I figured a flat structure would be easier to understand.
- thinkpad20 12y agoI was going to ask about this as well. It seems like there's a lot of wasted space in how things are represented. The first field already tells you what type of object you're dealing with. Since you're using 64-bit integers, you could represent pointers, bools, ints and floats all in the same memory space. I guess there might be some types that use more than one field, but certainly a bool is not going to. There's also the issue of alignment with the usage of 1-bit and 1-byte types...