sumtypes for D

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


On 11/29/22 15:31, rikki cattermole wrote:
> 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.

Oops. Moved it all over. I guess the corresponding messages in this 
thread can be deleted.


More information about the Digitalmars-d mailing list