draft proposal for Sum Types for D

Timon Gehr timon.gehr at gmx.ch
Tue Nov 29 20:53:54 UTC 2022


On 11/29/22 21:50, H. S. Teoh wrote:
>> 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.)

I guess the point is that in some contrast to structs, it may well be 
compatible in some cases, and it is important to know in which cases it 
remains compatible.


More information about the Digitalmars-d mailing list