sumtypes for D

rikki cattermole rikki at cattermole.co.nz
Tue Nov 29 14:31:03 UTC 2022


On 30/11/2022 3:24 AM, Timon Gehr wrote:
> 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.

Could you please post this on the new thread where the draft is linked?

It is a good feedback and in this thread it'll get lost.


More information about the Digitalmars-d mailing list