On Thursday 23 September 2010 19:27:19 Andrei Alexandrescu wrote: > On 09/23/2010 09:16 PM, Rioshin an'Harthen wrote: > > "Walter Bright" <newshou...@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
Indeed, though it might be okay to allow totally empty case statements on the theory that the programmer pretty much couldn't have meant anything other than fallthrough - though given that D has the syntax to do that as one case statement, it might be reasonable (and probably easier to implement) to not allow totally empty case statements. I don't really mind it how it is, but I've known plenty of programmers who hated the fallthrough behavior in other languages. So, it would likely be a good change to make. - Jonathan M Davis