draft proposal for Sum Types for D
H. S. Teoh
hsteoh at qfbox.info
Tue Nov 29 20:50:15 UTC 2022
On Tue, Nov 29, 2022 at 08:37:57PM +0000, Jacob Carlborg via Digitalmars-d wrote:
[...]
> ### ABI
>
> I think a section on ABI is missing. It should specify the memory
> layout of sumtypes, just as for existing language constructs [1].
Agreed.
> What's even more important than the memory layout is the value of the
> tag. Something needs to be specified in regards to the value of the
> tag. One needs to be able to draw some conclusions about what happens
> with the value if members are added, removed or reordered. Ideally the
> tag value of existing members should not change. These are important
> things when using sumtypes at ABI boundaries.
You can't dynamically change a sumtype (add/remove/reorder its
constituents) after the fact, because that may change their size, which
implies an ABI change. I think it's pretty much a given that you have
to recompile after any change to a sumtype's definition. (Just like you
have to recompile when you change a struct's definition -- since its
size may no longer be compatible with its old definition.)
T
--
Knowledge is that area of ignorance that we arrange and classify. -- Ambrose Bierce
More information about the Digitalmars-d
mailing list