Other languages with pattern matching include Prolog* , ML, and Erlang. (If I'm not mistaken, it originated with SNOBOL.) Awk also uses regular expression matching toward similar ends, but it's like comparing REs to a full parser.
* Prolog has unification, actually, which is more powerful than pattern matching. Instead of trying to match a value against a list of patterns, it tries to match two (or more) potentially partially-defined values against each other.
Pattern matching is one of my favorite language features. PM-based code is usually quite straightforward to read (especially compared to a jumble of nested 'if's!), and can be compiled to efficient decision trees. It also works well with both static typing (checking full coverage of ML-style variant types) and dynamic typing (such as with Erlang's receive). The closest thing most OO languages have is polymorphism, which tends to break up the pattern table into lots of little scattered ones (unless the language has multimethods), making it harder to see the big picture.
* Prolog has unification, actually, which is more powerful than pattern matching. Instead of trying to match a value against a list of patterns, it tries to match two (or more) potentially partially-defined values against each other.
Pattern matching is one of my favorite language features. PM-based code is usually quite straightforward to read (especially compared to a jumble of nested 'if's!), and can be compiled to efficient decision trees. It also works well with both static typing (checking full coverage of ML-style variant types) and dynamic typing (such as with Erlang's receive). The closest thing most OO languages have is polymorphism, which tends to break up the pattern table into lots of little scattered ones (unless the language has multimethods), making it harder to see the big picture.