Computer Software
Print ISSN : 0289-6540
A Fresh Look at Pattern Matching Compilation
Atsushi OHORISatoshi OSAKA
Author information
JOURNAL FREE ACCESS

2007 Volume 24 Issue 2 Pages 2_113-2_132

Details
Abstract
This paper presents a denotational semantics for patten matching compilation, and develops a simple algorithm to compile pattern matching into efficient code. We interpret a given set of patterns as a disjoint set of subsets of values that partition the domain of a given type, and define a semantics of a pattern matching construct as an operation to determine the subset to which a given value belongs. By developing tree representations for subsets of values, this semantics yields a simple tree-expansion algorithm to compile a pattern matching construct into a sequence of primitive tests. The resulting algorithm is shown to be correct with respect to the denotational semantics. The algorithm produces efficient code performing each test only once, and detects redundancy and non-exhaustiveness of a given set of patterns without introducing any additional mechanism. The presented method has been implemented for SML#, an extension of the Standard ML language being developed at Research Institute of Electrical Communication, Tohoku University.
Content from these authors
© Japan Society for Software Science and Technology 2007
Previous article Next article
feedback
Top