home ¦ Archives ¦ Atom ¦ RSS

Pattern Matching in Programs

Running across Matchure gave me good vibes regarding the utility of pattern matching in higher order programming languages. Pattern matching is still an undervalued mechanism in modern programming. A kissing cousin of Lisp macros, pattern matching is a nice high-level way to express tree structure matching and binding of matched substructure to variables. It’s simultaneously easy to decompose structures and immediately compute over the decomposition. Similar to regular expressions over strings, functional style patterns tend to look like the structures they’re trying to match.

I have a soft spot for pattern matching because in my dissertation I suggested that they would be a powerful addition to multimedia scripting languages, especially languages embedded in Web browsers. The pattern matching would be handy for dealing with the tree structure of HTML pages.

I was both wrong and right. Functional style pattern matching never did wind up in the browser. But XPath in JavaScript bears witness that tree destructuring is actually pretty useful. Every language could seemingly use pattern matching, but it’s exceedingly hard to embed in languages with Algol-style syntax.

© 2008-2024 C. Ross Jam. Built using Pelican. Theme based upon Giulio Fidente’s original svbhack, and slightly modified by crossjam.