Re: Go ahead. Stop programming. This ensures you from any mistakes.
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Sat, 9 Jun 2007 19:18:04 +0100
Ben Voigt [C++ MVP] <rbv@xxxxxxxxxxxxx> wrote:
Would you like to have the effect to a series of your program statements
by emulating the "fallthrough" by explicit goto after every statement? As
Bob http://www.bobcongdon.net/blog/2003/12/c-switch-statement.html points
it out, C# designers should introduce a "safe" must-break-switch rather
than "improving" the switch by disallowing fall-through and then adding
the goto junk.
No, forgetting a break is a common enough error that it's not unreasonable
to require an explicit flow control statement. What's wrong with C# is that
an MVP like Jon could not know that fall-through was available with the
"goto case" construct.
I'd say that's more of a fault with me than with the language :)
(Then again, there are various areas I don't know much about, if I try
not to use them anyway. I know very little about unsafe code, about
"goto" in general, and about any operator precedence which I wouldn't
want to assume that readers would know.)
The error message should be written more like:
Case block ended without flow transfer, you probably wanted "break" or "goto
case" but "return", "continue" or "throw" would also work.
That probably wouldn't have educated me, as I wouldn't have seen the
error often enough for it to be remembered.
And "continue" should definitely not be redefined to provide
fall-through, that would really make a confusing incompatibility with
C.
Yes, that's a fair point. How about continue with a case label? Still
too confusing? On balance, "goto" probably captures the intent
reasonably well.
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.
- References:
- already used in a 'child' scope to denote something else
- From: valentin tihomirov
- Re: already used in a 'child' scope to denote something else
- From: Jon Skeet [C# MVP]
- Go ahead. Stop programming. This ensures you from any mistakes.
- From: valentin tihomirov
- Re: Go ahead. Stop programming. This ensures you from any mistakes.
- From: Jon Skeet [C# MVP]
- Re: Go ahead. Stop programming. This ensures you from any mistakes.
- From: valentin tihomirov
- Re: Go ahead. Stop programming. This ensures you from any mistakes.
- From: Jon Skeet [C# MVP]
- Re: Go ahead. Stop programming. This ensures you from any mistakes.
- From: valentin tihomirov
- Re: Go ahead. Stop programming. This ensures you from any mistakes.
- From: Jon Skeet [C# MVP]
- Re: Go ahead. Stop programming. This ensures you from any mistakes.
- From: valentin tihomirov
- Re: Go ahead. Stop programming. This ensures you from any mistakes.
- From: Ben Voigt [C++ MVP]
- already used in a 'child' scope to denote something else
- Prev by Date: Re: Go ahead. Stop programming. This ensures you from any mistakes.
- Next by Date: Re: Go ahead. Stop programming. This ensures you from any mistakes.
- Previous by thread: Re: Go ahead. Stop programming. This ensures you from any mistakes.
- Next by thread: Re: Go ahead. Stop programming. This ensures you from any mistakes.
- Index(es):
Relevant Pages
|