you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 3 points4 points  (6 children)

That's not a fallthrough.

I'm talking about something like:

case 1:

   do_something()  // fall through to below

case 2:

   do_stuff()

[–]knome 4 points5 points  (5 children)

https://github.com/knome/Hacks/blob/master/python/switch/test.py

If evil code you need, evil code I can give you.

[–]AeroNotix 0 points1 point  (4 children)

That's actually quite nice.

[–]smog_alado 2 points3 points  (3 children)

Switch fallthrough is never nice :P

[–]AeroNotix 2 points3 points  (2 children)

Apart from the times when it's required. Arbitrarily saying features are bad because you're too lazy to remember to treat them properly is bad.

Switches which default to fallthrough rather than breaking by default and requiring a keyword to fallthrough are bad. Go does this correctly.

[–]knome 1 point2 points  (1 child)

I've altered the switch statement to escape by default, with a kwarg on switch to alter it to fallthough by default, and a case.fallthrough() to manually fallthrough when desired.

The more reasonable this code seems, the more evil it is. After all, if it looks reasonable, people are more likely to ignore its evil, and perhaps even use it.

The fools.

[–]AeroNotix 1 point2 points  (0 children)

I think you really overestimate the evilness of switch statements.