On 2/17/14, 7:31 PM, Walter Bright wrote:
On 2/17/2014 5:48 AM, Ary Borenszweig wrote:
On 2/16/14, 5:03 PM, Walter Bright wrote:
It originally was not required, but there was a campaign by a lot of D
users to make it required to deal with the common bug of adding a value
in one switch statement but forgetting to add it to another
corresponding one.
Could you show an example of such scenario? I don't get it.
Having a set of bit flags, and adding another bit flag later, and
failing to account for that in existing switch statements.
auto bit_flag = ...;
switch(bit_flag) {
case old_bit_flag_1:
// do something
break;
case old_bit_flag_2:
// do something
break;
default:
break;
}
Now suppose bit_flag can get an additional "new_bit_flag" value. How
does "default" helps me notice that I'm supposed to add it to that
switch statement?
I still can't see your point :-(
Maybe I need some more example code to understand it.