Second draft: Sum Type by Struct

monkyyy crazymonkyyy at gmail.com
Thu Sep 3 14:07:31 UTC 2026


On Thursday, 3 September 2026 at 11:45:12 UTC, Richard (Rikki) 
Andrew Cattermole wrote:
> If all covered AND catch-all present → error: redundant 
> catch-all

breaks meta programming norms for no reason; trailing comma 
reasoning

> Variants	Tag Type	Size
> 1–256	ubyte	1 byte

0-1 variants should have a tag of void[0] or something

`__sumtype mynone=None;`

> None as the basis for Option

Im not seeing a pointer, like none you expand the field by 1 and 
it cleans up allot downstream.

`__sumtype opt=None|int|float|opt*` does it naturally just work? 
or will it need a keyword like `this*`

> The generated members are the same as the non-template form. 
> For S!(int, string) — int | string | bool — the lowered struct 
> has six members: tag, __v0, __v1, __v2, toHash, and opCmp:
> static assert(__traits(allMembers, S!(int, string)).length == 
> 6);

this is a bad trait given that metaprogramming will want to 
access the type list

`alias gettypes(Sumtype)= 
StaticMap!(templatetypeof,__traits(allMembers,SumType)[1..$-2]);` 
does N inits and thats with assumptions phoboes will not make and 
theyll add a filter, add an contract, etc. etc. etc.

but the data should just be there somewhere, just add a new trait.


More information about the dip.development mailing list