Enumerated Unions (sum types)

Dukc ajieskola at gmail.com
Thu Sep 12 12:13:20 UTC 2024


On Thursday, 12 September 2024 at 12:01:38 UTC, Paul Backus wrote:
>
> The sum type will have a `.sizeof` property that gives its 
> total size, with the tag field included.
>
> When the DIP says "the size of the tag field is unspecified," 
> what that means is that it's unspecified is how much of the 
> "extra" space is actually used for the tag field, and how much 
> of it is padding.

That still means the foreign code will have to account for each 
different D compiler it's going to support, even when the D 
compilers are built the same C ABI.

Then again, this is a pretty theoretical argument since all the 
widely used D compilers are currently based on the same frontend 
and would therefore probably have the same ABI for the same C ABI 
in practice. So maybe it's worth to nail it down only if/when 
different D frontends start to see widespread use.


More information about the dip.ideas mailing list