3 ms·
Switch is a strange relic of C. According to https://en.wikipedia.org/wiki/Switch_statement#Fallthrough https://en.wikipedia.org/wiki/Switch_statement#Fallthrou
by chriswarbo 6y ago
Switch is a strange relic of C. According to https://en.wikipedia.org/wiki/Switch_statement#Fallthrough https://en.wikipedia.org/wiki/Switch_statement#Fallthrough the fallthrough behaviour is due to it being implemented as a thin veneer over computed GOTOs. It seems to have infected a surprising number of languages, probably due to a mixture of C's popularity, cargo-culting and Stockholm syndrome.
I'm very glad Python never got C-style switch.
As for Scala, its pattern-matching (among other things!) ultimately comes from ML in the 1970s (its modern descendents being StandardML and Ocaml, and to a lesser extent Scala, Haskell and Rust).