case statements

Ellery Newcomer ellery-newcomer at utulsa.edu
Sat Oct 10 17:45:23 PDT 2009


This is probably a bad idea, but from my readings of the dmd source, I
noticed some preprocessor defines that looked useful, along the lines of

#define CASES case A:case B: (etc)

I'd kinda like something similar in D, but a naive attempt with mixins
doesn't work, e.g.

immutable string cases = "case 1: case 2:"; //my d2fu sucks

..

switch(x){
    mixin(cases);
      dosomething();
    default:
      dosomething();
}

Any ideas (not including concatenating cases with body of case)?


More information about the Digitalmars-d-learn mailing list