An end to implicit fall-throughs in the kernel
An end to implicit fall-throughs in the kernel
Posted Aug 5, 2019 14:53 UTC (Mon) by karkhaz (subscriber, #99844)In reply to: An end to implicit fall-throughs in the kernel by rweikusat2
Parent article: An end to implicit fall-throughs in the kernel
Nobody learns C by reading the standard. People instead use the same mental model for switch statements that they do for if statements, i.e., they are two different ways of writing a conditional expression.
Since you only ever take (at most) one branch of an if statement, it makes sense that programmers expect the same behaviour from the cases of a switch statement. Unlearning this mental model is difficult because people rarely use goto statements and commonly use if statements. So for most people, switch statements are a syntactic sugar for if statements (removing the need to explicitly test the value of the expression for each branch), rather than being sugar for goto statements.