sumtypes for D
Timon Gehr
timon.gehr at gmx.ch
Tue Nov 29 14:24:39 UTC 2022
On 11/29/22 08:26, Walter Bright wrote:
> On 11/28/2022 6:53 PM, Adam D Ruppe wrote:
>> Curious, what did you find lacking in std.sumtype?
>>
>> Same question to Walter.
>
> It's addressed in the draft DIP I just posted.
>
> 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