Sum Type by Struct

IchorDev zxinsworld at gmail.com
Sun Sep 22 10:43:38 UTC 2024


On Thursday, 12 September 2024 at 11:28:56 UTC, Richard (Rikki) 
Andrew Cattermole wrote:
> In this proposal I propose a third sumtype design, one in which 
> it is based upon structs.

One huge improvement would be to make the declaration syntax the 
same as that of structs as well. This would make it more 
consistent with the rest of the language, and allow conditional 
compilation statements, and potentially things like constructors 
and member functions. I suggest a `case` prefix like in Swift:
```d
sumtype A{
   version(Nullable) case :None;
   case int, string text;
}
```


More information about the dip.ideas mailing list