bool concat patternmatching with switch

monkyyy crazymonkyyy at gmail.com
Tue May 28 19:39:45 UTC 2024


```d
switch(i%3==0,i%5==0){
   case 1,1: return "fizzbuzz";
   case 0,1: return "buzz";
   case 1,0: return "fizz";
   case ?,?: return i.to!string;
}
```

adding full pattern matching to d seems unlikely to me; but I 
think something should be done to improve ugly if else chains as 
d's switch statements are extremely out of date compared to other 
languages.

I propose syntax sugar where if you pass multible bools (and 
maybe small enums), it will bitshift theses into int and call the 
same basic asm pattern c used for its switch statements.



More information about the dip.ideas mailing list