Allow Conditional Compilation Inside Enum Declaration
monkyyy
crazymonkyyy at gmail.com
Sat Mar 30 22:34:46 UTC 2024
On Saturday, 30 March 2024 at 14:57:00 UTC, IchorDev wrote:
> To declare an enum type that may or may not have one or more
> members depending on conditional compilation statements
> requires duplicating the entire enum:
> ```d
> static if(cond){
> enum A{
> x,y,z,w,
> }
> }else{
> enum A{
> x,y,z,
> }
> }
> ```
>
> For an enum type with many members—or many conditionals—this
> quickly becomes an insane amount of repetition.
>
> The logical solution is to just allow conditional compilation
> statements inside enums:
> ```d
> enum A{
> x,y,z,
> static if(cond){
> w,
> }
> }
> ```
As a specif case or for all lists?
Could you do this for functions `foo(static if(bar){1},2)`?
is changing the meaning of {} nessery or should it be for single
elements?
`enum A{x,y,z, static if(cond) w}`
More information about the dip.ideas
mailing list