Yes, you could indeed use type IDs in that way. Also worth noting that if someone accidentally reuses an ID and tried to link both schemas into the same program, they'll get a linker error.
-Kenton On Mon, Jun 10, 2019, 7:10 AM <[email protected]> wrote: > I was looking deeper at the ids, and noticed something I'd missed. Capnp > generates ids for every type automatically. > > If I understand it correctly, the auto-generated ID depends on the ID of > the parent scope and the item's name, nothing else. If that's correct, then > using this might work. > > If I don't give them an example schema with a file id, then the only way > to get a bad duplicate ID would be to copy their own schema, and not change > a structure name, and also change its internals incompatibly. Which would > only break their own stuff, not properly functioning already existing code. > Or really bad luck. > > And sending a > struct SchemaID { > id @0 :Int64; > } > Is easy. > > Am I understanding the id generation properly? > > -- > 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/1eede382-113c-440b-99a4-c8e81657b683%40googlegroups.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/CAJouXQmCX1xf0nPWHev8HWRAhcMGZaDkSwZfAPBvTf%2BD6dEf6w%40mail.gmail.com.
