No case ranges in final switches?

bearophile bearophileHUGS at lycos.com
Sun Mar 6 13:11:00 PST 2011


Do you know why final switches disallow case ranges? Case ranges are not bug-prone:


void main() {
    ubyte u;
    final switch (u) {
        case 0: .. case 100:
            break;
        case 101: .. case 255:
            break;
    }
}


DMD 2.052 gives the errors:
test.d(4): Error: case ranges not allowed in final switch
test.d(6): Error: case ranges not allowed in final switch

Thank you and bye,
bearophile


More information about the Digitalmars-d-learn mailing list