Re: Go ahead. Stop programming. This ensures you from any mistakes.




"valentin tihomirov" <V_tihomirov@xxxxxxx> wrote in message news:e$HQhwrqHHA.484@xxxxxxxxxxxxxxxxxxxxxxx
Right - and likewise, the only way it seems that you'll stop being
cross about things that C# stops you from doing is to stop using C#.

.. and invent my own language+OS and ... if aI do not like the decisions made by men in power.


Compiler, grammar is needed to protect from doing nonsense, like assinging
date to a boolean or using unassigned variable or writing into constant
memory. It should not protect you from doing sensable things like writng
integer const to integer var or defining a not yet defined variable or
executing statements one after another.

Well, I'm sure I'm not the only one who's been bitten by accidental
fallthrough in switch statements in C. As I said, I would prefer a more
radical overhaul of switch/case, but I'd rather have what we've got
than a version which has all the ugliness of the current version but
with the added problem of fallthrough.

If you were bitten for omitting a statement, it does not mean that this statememt must be incorporated into the grammar.


As Ben pointed out, you can always use goto case if you really want the
effect of fallthrough.

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. 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. And "continue" should definitely not be redefined to provide fall-through, that would really make a confusing incompatibility with C.

.



Relevant Pages