Enumerated Unions (sum types)
Dukc
ajieskola at gmail.com
Thu Sep 12 10:32:39 UTC 2024
On Thursday, 12 September 2024 at 09:56:44 UTC, Paul Backus wrote:
>> Also I propose that the tag type is enumerated type that is
>> implicitly convertible to `int`. The base type is an unsigned
>> integer type big enough to hold all the field types. Default
>> value and the enumerated values (other than having one for
>> each type) can remain unspecified though.
>
> By "tag type" I assume you mean the type of the __tag property.
> Is there any practical difference between what you describe and
> just using size_t?
Well, `size_t` takes more space. Then again, if the tag property
would be a getter as opposed to a direct field accessor the tag
type wouldn't necessarily have to match with the real type of the
tag field, in which case there's no difference.
More information about the dip.ideas
mailing list