On Mon, 17 Feb 2014 18:01:38 -0500, Walter Bright <[email protected]> wrote:

On 2/17/2014 2:43 PM, Ary Borenszweig wrote:
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?

Because if you account for all the cases, you write:

    default: assert(0);

Now you intentionally tell the user that you intentionally covered all the cases.

Would it not be better to infer this, and you could override it by doing default: break;?

If that's the "right way", then it should be the default way.

I agree with Ary. Sequence will go as follows:

Programmer:

switch(x)
{
   case 1: statement; break;
}

Compiler: no no no, you need a default case!

Programmer: "Oh fine!"

switch(x)
{
   case 1: statement; break;
   default: break;
}

How is this advantageous? It just seems annoying...

-Steve

Reply via email to