draft proposal for Sum Types for D

Timon Gehr timon.gehr at gmx.ch
Tue Nov 29 14:46:35 UTC 2022


On 11/29/22 07:26, Walter Bright wrote:
> Go ahead, Make My Day! Destroy!
> 
> https://github.com/WalterBright/DIPs/blob/sumtypes/DIPs/1NNN-(wgb).md


Maybe consider changing the syntax to something like:

sumtype ST{
     a;
     int* b;
}

The reason is that with comma-separated values, metaprogramming is hobbled.

I think we really want to be able to do things like:

sumtype ST(bool hasC){
     a;
     int* b;
     static if(hasC){
         float c;
     }
}

Similar for `static foreach`. The fact that this does not work for 
`enum`s is among the most annoying limitations of `enum`s.


More information about the Digitalmars-d mailing list