Pattern matching is a popular feature in functional, imperative and object-oriented programming languages. Language designers should therefore invest effort in a good design for pattern matching. Most languages choose a first-match semantics for pattern matching; that is, clauses are tried in the order in which they appear in the program until the first one matches. As a consequence, the order in which the clauses appear cannot be arbitrarily changed, which results in a less declarative programming model. The declarative alternative to this is an order-independent semantics for pattern matching, which is not implemented in most programming languages since it requires more verbose patterns. The reason for this verbosity is that the syntax of patterns is usually not expressive enough to express the complement of a pattern. In this paper, we show a principled way to make order-independent pattern matching practical. Our solution consists of two parts: First, we introduce a boolean algebra of patterns which can express the complement of a pattern. Second, we introduce default clauses to pattern matches. These default clauses capture the essential idea of a fallthrough case without sacrificing the property of order-independence.
Mon 30 JunDisplayed time zone: Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna change
11:00 - 12:45 | Formal Methods, Logics, and Static Analysis FrameworksTechnical Papers at Auditorium M003 Chair(s): Marco Carbone IT University of Copenhagen | ||
11:00 21mTalk | Compositional Static Value Analysis for Higher-Order Numerical Programs Technical Papers Milla Valnet Sorbonne Université, Raphaël Monat Inria and University of Lille, Antoine Miné Sorbonne Université | ||
11:21 21mTalk | Lightweight Diagramming for Formal Methods: A Grounded Language Design Technical Papers Siddhartha Prasad Brown University, Ben Greenman University of Utah, Tim Nelson Brown University, Shriram Krishnamurthi Brown University | ||
11:42 21mTalk | Taming and Dissecting Recursions through Interprocedural Weak Topological Ordering Technical Papers Jiawei Yang , Xiao Cheng Macquarie University, Bor-Yuh Evan Chang University of Colorado Boulder & Amazon, Xiapu Luo Hong Kong Polytechnic University, Yulei Sui University of New South Wales | ||
12:03 21mTalk | The Algebra of Patterns Technical Papers | ||
12:24 21mTalk | A theory of (linear-time) timed monitors Technical Papers Mouloud Amara IRIF, Université Paris Cité, Giovanni Bernardi IRIF, Université Paris Cité, Mohammed Aristide Foughali Université Paris Cité / IRIF, Adrian Francalanza University of Malta | ||