Hi Yaron, Ian already answered the question, but I thought I'd add:
For protocols that are published publicly and used by arbitrary parties that you don't control, retroactive unionization may indeed be too unsafe to really use. Many protocols, though, are used privately between components of a system. In this case, forwards- and backwards-compatibility may be important in order to allow components to be updated independently, but compatibility only needs to extend between all components that are currently in production. In that case, it's quite common to do something like: 1) Retroactively unionize a field, but don't actually use them new variant yet. 2) Update each component that receives messages of the modified type, so that they are aware of the union. 3) Now, start setting the new variant where desired. -Kenton On Tue, May 14, 2019 at 1:06 PM Yaron Minsky <[email protected]> wrote: > Retroactive unionization is only backwards compatible, not forward > compatible, right? So, if I start with this struct: > > struct Person { > name @0 :Text; > email @1 :Text; > } > > And decide that I want to evolve it to this one: > > struct Person { > name @0 :Text; > union { > email @1 :Text; > age @2 :Float64; > } > } > > (I know it's not a very meaningful example). > > If I write something in the new spec that uses the age branch of the > union, the old struct can try to read it, and get very confused. In > particular, if someone tries to read the email for a struct that > actually populates age, they'll end up reading a Float64 as if it were > a pointer to a text block. > > Am I understanding the issue correctly? If so, how do people handle > these kinds of protocol changes? Do people use retroactive > unionization in practice? Do people use schema validation of some > kind to detect when someone makes a potentially unsafe change like > this one? > > y > > -- > You received this message because you are subscribed to the Google Groups > "Cap'n Proto" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > Visit this group at https://groups.google.com/group/capnproto. > To view this discussion on the web visit > https://groups.google.com/d/msgid/capnproto/CACLX4jRucxh5%2BmrvkkbcvTgmEbxeAcY%2BEJa4XKw5y_-DZGHorQ%40mail.gmail.com > . > -- You received this message because you are subscribed to the Google Groups "Cap'n Proto" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. Visit this group at https://groups.google.com/group/capnproto. To view this discussion on the web visit https://groups.google.com/d/msgid/capnproto/CAJouXQkNU%2BiosP5F%2BBhzJDyaumO691C42frV2my8YDkV0j%2BMSA%40mail.gmail.com.
