switch()

Chris Cain clcain at uncg.edu
Sun Feb 16 08:04:52 PST 2014


I think the main reason why switches work this way (and 
cannot/should not be changed) is because of one of the main 
design goals of D:

http://dlang.org/overview.html

#7: Where D code looks the same as C code, have it either behave 
the same or issue an error.

The proposed changes would violate this, making existing C code 
change meaning silently (wrt implicit "break;" in particular).

TBH, though, I agree that this is somewhat of a speed bump in D. 
I really rarely find myself using switches because of the same 
issues you mention. Unfortunately, without adding new syntax 
(which is also problematic for many reasons), such a thing cannot 
be fixed unless this goal is ignored.


More information about the Digitalmars-d mailing list