Should the 2.054 feature about warning on implicit fallthrough

Dmitry Olshansky dmitry.olsh at gmail.com
Wed Sep 14 14:17:38 PDT 2011


On 15.09.2011 0:51, bearophile wrote:
> 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.
>
It depends on what you need it to do.
If all you need is jump table then C switch is your best friend.

>
>> 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.
>
+1.

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


-- 
Dmitry Olshansky


More information about the Digitalmars-d-learn mailing list