The Wrong Stuff
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Thu Sep 23 19:27:19 PDT 2010
On 09/23/2010 09:16 PM, Rioshin an'Harthen wrote:
> "Walter Bright" <newshound2 at digitalmars.com> wrote:
>> Errors that we can eliminate by changing the design of the
>> language, we should so eliminate (unless their costs make the language
>> unuseable, obviously).
>
> So are you returning to the very bad design error in switch
> statements? ;) Silent fall-through is bad, and keeps hitting
> quite a few programmers - I don't have any links handy
> right now, but I do remember it has been talked over before
> here. What I'd like to see is requiring either a continue or
> a break at the end of a case to make the intent clear. The
> "problem" would be empty cases, as is the typical C-style
> method to get multiple values to do the same thing, but these
> have already been fixed in the language design with multiple
> values per case statement and ranged case statements.
>
> One of the general design principles of D has been "if it
> compiles in C, it compiles in D and does the same thing or
> it does not compile at all", if I remember correctly. I would
> really like to see the C-style silent fallthrough to be a compile
> time error, which would not contradict that design principle.
> And if you have a lot of code that relies on this misfeature,
> then it does not take long to add continue statements where
> they're needed - not even if translating C source to D.
The correct change is not to require break or continue - it's to require
any control flow statement.
Andrei
More information about the Digitalmars-d
mailing list