Allow Conditional Compilation Inside Enum Declaration

monkyyy crazymonkyyy at gmail.com
Sun Mar 31 15:05:38 UTC 2024


On Sunday, 31 March 2024 at 02:36:40 UTC, IchorDev wrote:
> On Saturday, 30 March 2024 at 22:34:46 UTC, monkyyy wrote:
>> As a [specific] case or for all lists?
>>
>> Could you do this for functions `foo(static if(bar){1},2)`?
>
> I’m not sure if that’s really in the scope of this idea. Maybe 
> that could be another proposal?
>
>> is changing the meaning of {} nessery or should it be for 
>> single elements?
>> `enum A{x,y,z, static if(cond) w}`
>
> I don’t see why that would be necessary? Ideally it should work 
> just like any existing conditional compilation. (e.g. also 
> allowing `version(Something):`, etc.)

While I can't mimik what the mathy compiler devs will say I'm 
pretty sure existing static if must be in a very different level 
of the compiler then enum parsing.

One of the bugs I reported was about meta programming enums using 
user types op overloads (where +1, would be treated as x2 for 
flags) I think x,y,z,w are fragile order of operation values and 
any attempt to meta program them would be "you have to go full 
string mixin and do everything all at once"

So in my head this compile time version of if as a code block and 
ternary if and a version of this feature with the logic "if 
static condation is met, parse this element to parent node, 
otherwise skip" that works like the auto flattening of sequences 
seems more likely


More information about the dip.ideas mailing list