| ▲ | p1necone 2 hours ago | |
One simple but non obvious (at least to me) trick when implementing tagged unions: put the union discriminator/tag at the end, not the beginning - that way a pointer to a union is also a pointer to the value, no need to increment the pointer to point past the tag after discriminating. | ||
| ▲ | beached_whale an hour ago | parent [-] | |
when serializing these things it's generally going to be best to put the tag first though. That way it's cheap to figure out how to parse it. | ||