Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
Fast-Nop771626dThe end of one case is the next case or default. Easy.
C's behaviour is because whoever came up with that idea was clearly thinking in assembly. Then again, all good C programmers think in assembly anyway so that it's no big deal.
xcodesucks34425dWell, in Pascal the Case statement does not fall through and in Swift, the switch does not fall through. Actually, it kinda says something... "Safety Belts"
These are languages that are not as concerned with performance as they are concerned with safety for the junior programmer and keeping them from ripping their hair out over beginner bugs.
Stacking a bunch of cases that match a single condition... or putting some "special cases" on top of a base case to leverage the fall-through is the natural way to think when working threads or pre-emptive interrupt work.
As others have said, C thinkers think at the machine level... in assembly. Someone who writes in C stands a good chance of being very handy with a soldering iron. Someone who writes in Pascal or Swift probably could not tell you what a soldering iron looked like.
Fast-Nop771625d@xcodesucks GCC 7 and later has an interesting warning. If the case falls through and is not empty, a comment in certain format is required.
When upgrading GCC, I got bitten by that one in conjunction with my usual -Werror because I obviously had a comment there, but that was from long before the GCC team decided on the recognised format.
And I do have a soldering iron for doing electronics, you got me on that one. :-)
wowotek406725dthis is actually make sense if you ever programmed in Assembly, at least ARM
RememberMe671325dAh, check out pattern matching in a ML-family functional programming language like SML, OCaml, F#, or Haskell
thomasd36925dThe fall through can be very useful
Root3552025dAssembly is amazing, and case fallthrough is super useful. *nod*
Your Job Suck?
Take a quick quiz from Triplebyte to skip the job search hassles and jump to final interviews at hot tech firms
Get a Better Job