Allow Conditional Compilation Inside Enum Declaration

IchorDev zxinsworld at gmail.com
Sat Mar 30 14:57:00 UTC 2024


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,
	}
}
```


More information about the dip.ideas mailing list