Pattern Matching in an Open World
Pattern matching is a pervasive and useful feature in functional programming. There have been many attempts to bring similar notions to Object-Oriented Programming (OOP) in the past. However, a key challenge in OOP is how pattern matching can coexist with the open nature of OOP data structures, while at the same time guaranteeing other desirable properties for pattern matching.
This paper discusses several desirable properties for pattern matching in an OOP context, and shows how existing approaches are lacking some of these properties. We argue that the traditional semantics of pattern matching, which is based on the order of patterns and adopted by many approaches, is in conflict with the openness of data structures. Therefore we suggest that a more restricted, top-level pattern matching model, where the order of patterns is irrelevant is worthwhile considering in an OOP context. To compensate for the absence of ordered patterns we propose a complementary mechanism for case analysis with defaults, which can be used when nested and/or multiple case analysis is needed. To illustrate our points we develop Castor: a metaprogramming library in Scala that adopts both ideas. Castor generates code that uses type-safe extensible visitors, and largely removes boilerplate code typically associated with visitors. We illustrate the applicability of our approach with a case study modularizing the interpreters in the famous book “Types and Programming Languages”.
Tue 6 NovDisplayed time zone: Guadalajara, Mexico City, Monterrey change
10:30 - 12:00 | |||
10:30 30mTalk | Measuring Effectiveness of Sample-based Product-Line Testing GPCE 2018 Sebastian Ruland , Lars Luthmann TU Darmstadt, Real-time Systems Lab, Johannes Bürdek TU Darmstadt, Real-time Systems Lab, Sascha Lity Technische Universität Braunschweig, Thomas Thüm University of Ulm, Malte Lochau , Márcio Ribeiro Federal University of Alagoas, Brazil | ||
11:00 30mTalk | Pattern Matching in an Open World GPCE 2018 | ||
11:30 30mTalk | Verification of High-Level Transformations with Inductive Refinement Types GPCE 2018 Ahmad Salim Al-Sibahi Department of Computer Science, University of Copenhagen (DIKU) & BilagScan, Thomas P. Jensen INRIA Rennes, Aleksandar S. Dimovski IT University of Copenhagen, Denmark, Andrzej Wąsowski IT University of Copenhagen, Denmark |