This is an experimental exploration of the pattern-driven programming paradigm—the sole use of pattern matching to determine the next instruction or execute. We define a pure pattern-driven programming language named PA-Scala by defining a subset of the Scala programming language, which restricts sequence control to the powerful pattern matching facilities in Scala. We use PA-Scala to explore the strengths and limitations of pattern-driven programming. By implementing a phrase structure grammar solver in PA-Scala, we show that pattern-driven programming can be used to solve general computation problems. We then implement a Prolog interpreter in PA-Scala, which demonstrates how resolution and unification can be implemented in PA-Scala. Finally we analyzed the possibility of parallel execution for PA-Scala, and show that pattern-driven programming also has the potential to achieve performance improvements by running pattern matching operations in parallel.
Pang, Huaxin, "Pattern-driven Programming in Scala" (2015). Master's Projects. 437.