Re:The security hole in sudo
by natesm on Wednesday May 23, 2012 @11:18AM
(#4013452)
C# doesn't have fallthrough at all, but it won't compile without "break;". I'm really not sure what they were going for there.
[ Parent
| on HN ]
You can "goto" any case label in C#, which works like fallthrough but is more flexible (since you can jump anywhere). At the same time, it avoids the refactoring hazard associated with fallthrough, in which changing the order of the switch labels can change the behavior of the code. Of the languages that have "switch" (not counting ML/Haskell-style pattern matching here), C#'s approach seems ideal.
The C# approach sounds like a recipe for abuse:
switch(something)
{
case 1:
// Do stuff
goto case 4;
case 2:
// Do stuff
goto case 1;
case 3:
// Do stuff
goto case 5;
case 4:
// Do stuff
goto case 3;
case 5:
// Do stuff
break;
}
Re:The security hole in sudo
by PotatoEngineer on Thursday May 24, 2012 @01:22PM
(#4019472)
That's quite horrible! Fortunately, it's obviously horrible, and since "goto" has such a stigma attached to it, programmers will only use it when it's necessary. (Cross your fingers.)
register_globals would like to have a word with you.
I agree that removing implicit fallthrough is good, since it's a 90%/10% feature, but my problem is that the "break;" is meaningless extra syntax, since the lack of it generates a compiler error.
C# already implies no implicit fallthrough, so there's no need to explicitly state that you're not falling through. A better solution (for every language, really) would be a "fallthrough;" statement or "goto case x;", which C# does get right.
Re:The security hole in sudo
by TazeTSchnitzel on Wednesday May 23, 2012 @11:26AM
(#4013504)
So Java and C++ programmers don't panic and think the whole thing will fall through.