Refactoring Code

Salih Dincer salihdb at hotmail.com
Thu Mar 21 20:56:21 UTC 2024


On Saturday, 2 March 2024 at 20:27:59 UTC, Walter Bright wrote:
> https://github.com/dlang/dmd/pull/16280/files
>
> Sometimes if you stare at code long enough, its underlying 
> simplicity emerges.

The same ```if()``` blocks will be created for the ```switch 
case``` for the already generated assembly code; ```switch 
case``` can also be used if you're happy to see it this way:

```d
with (Id) with (CppOperator)
{
     switch(id)
     {
         case _cast      : return Cast;
         case assign     : return Assign;
         case eq         : return Eq;
         case index      : return Index;
         case call       : return Call;
         case opUnary    : return Unary;
         case opBinary   : return Binary;
         case opOpAssign : return OpAssign;
         default         : return Unknown;
     }
}
```
SDB at 79


More information about the Digitalmars-d mailing list