January 08, 2008
S. Wrote:
> Programming requires a brain.
> 
> You should go read DailyWTF for awhile.  It is possible to do the most ridiculous things no matter how carefully the language is crafted.  We should just stay away from hand-holding and focus on making things easier.


You're right that we're capable of doing any and all kinds of stupid things.  I'm guilty of missing semicolons, break statements, and all kinds of other stuff.  Bugs pop up everywhere.  The easier they are for the compiler to spot and the simpler it is for a human to spot, the better.  Debugging is not just the job of the programmer who wrote code 5 minutes ago, but also the maintainer 6 months down the road.  I also like this quote from the pragmatic programmer: "It's not about if you'll remember, it's about when you'll forget"

I consider discussions on making switch statements safer a valid and important discussion...  One of my attractions to D is that it's willing to change stuff we hold near and dear in order to find a better way of doing things.

My personal take on all this switch stuff is:
  * Silently falling-through is dangerous
     (common switch error when coding, easy to miss in code review)
  * Silently not falling-through is dangerous (to C coders, etc)
  * A single case with commas is great, but won't be used by all
  * {} syntax may be a reasonable compromise
  * Explicitly requiring "break", "fall", or "assert(0)" at the end of a case may be the best solution.

January 09, 2008
"Jason House" <jason.james.house@gmail.com> kirjoitti viestissä news:fm05pk$2v7k$1@digitalmars.com...
> My personal take on all this switch stuff is:
>  * Silently falling-through is dangerous
>     (common switch error when coding, easy to miss in code review)
>  * Silently not falling-through is dangerous (to C coders, etc)
>  * A single case with commas is great, but won't be used by all
>  * {} syntax may be a reasonable compromise
>  * Explicitly requiring "break", "fall", or "assert(0)" at the end of a case
>     may be the best solution.

I'd like to see either a "break", "continue", or "return" (or any other
means of exiting a case, like "goto") at the end of a case statement
required, but I'd settle for the compiler to at least produce a warning
in the case one of these are missing. "continue" at the end of the case
statement would mean fall-through behavior, all others are as is.