bool concat patternmatching with switch

Basile B. b2.temp at gmx.com
Thu May 30 11:36:37 UTC 2024


On Wednesday, 29 May 2024 at 08:59:10 UTC, Dennis wrote:
> On Tuesday, 28 May 2024 at 19:39:45 UTC, monkyyy wrote:
>> 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.
>
> Something like that happens in DMD's source with an `X` 
> function:
>
> https://github.com/dlang/dmd/blob/d1f5a7ebd251b3df263a3c6ff87cac4aa9be309c/compiler/src/dmd/e2ir.d#L4770-L4792
>
> You could generalize it up to 64 bits that way.

It's even a pattern I'd say, there is also this one:

https://github.com/dlang/dmd/blob/377613993d35e425dfa43a3cc5cfe4c60acb7607/compiler/src/dmd/dtemplate.d#L1078

In my opinion it would be better to have a builtin "set of 
enum-member" construct and "set of enum-member"-literals, that 
are switchable (as essentially they are some integer values). 
Problems arise when the count of members is > 64 tho.


More information about the dip.ideas mailing list