Should the 2.054 feature about warning on implicit fallthrough

bearophile bearophileHUGS at lycos.com
Wed Sep 14 13:51:54 PDT 2011


Timon Gehr:

> I think it is a bit mean to say the whole semantics is a mess,

The original C design is a mess with several traps, and successive things added in D to the switch have increased the mess, they were designed from very narrow points of view, with a lack of global vision:

1) The case x: .. case y: syntax is ugly, and it doesn't respect the semantics of the .. in D that means a range open on the right.

2) The introduction of final switches is badly designed and not complete, so the safety of the situation is not improved:
http://d.puremagic.com/issues/show_bug.cgi?id=5713

3) The recent improvements (that are patches on the stupid semantics of the C switch) are buggy and need a patch:
https://github.com/D-Programming-Language/dmd/pull/370

Switch is too much limited, ignoring other needs:
http://d.puremagic.com/issues/show_bug.cgi?id=596

I'll never agree that the C switch is well (or even "well enough") designed. Even a simple language as Pascal gets the case-of statement better than C.


> switch statements and gotos provide nice means of writing highly 
> efficient code that still looks somewhat structured.

I'd like computed gotos in D. I have discussed with Walter often about this, but he doesn't listen much on this.


> Well, yes, but that is as expected. Would you expect a fall through 
> error on this code?

Have you run that code?

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list