Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>Cap’n Proto unions are not first class types. Instead, they are fields of structs

In some binary data description format, I didn't include unions because they are just a special case of what I called "conditional sequences". But then I added them, because it is very difficult or impossible to figure out whether a set of conditional sequences corresponds to a union (all must have same size, which is only known at encoding/decoding, and only one must be present), which you need to know when converting into more restrictive formats that only support unions.



Indeed, there's a good reason why sums (unions) and products (records) are the most primitive abstractions in various logics and mathematics.


Is there any serialization format that handles (discriminated) unions well?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: