4 ms·
So the same idea as pattern matching in Scala? If it can be used as switch case on steroids then I am all for it. Why Python never got switch case is an inter
by sireat 6y ago
So the same idea as pattern matching in Scala?
If it can be used as switch case on steroids then I am all for it.
Why Python never got switch case is an interesting question.
- chriswarbo 6y agoSwitch 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).