Abstract
Pattern matching makes ML programs more concise and readable, and these qualities are also sought in object-oriented settings. However, objects and classes come with open class hierarchies, extensibility requirements and the need for data abstraction, which all conflict with matching on concrete data types. Extractor-based pattern matching has been proposed to address this conflict. Extractors are user-defined methods that perform the task of value discrimination and deconstruction during pattern matching. In this paper, we give the first formalization of extractor-based matching, using a first-order object-oriented calculus. We give a direct operational semantics and prove it sound. We then present an optimizing translation to a target language without matching, and prove a correctness result stating that an expression is equivalent to its translation.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsPreview
Unable to display preview. Download preview PDF.
References
Burstall, R.M.: Proving properties of programs by inductive definitions. Computer 41–48 (1969)
Wadler, P.: Pattern Matching. In: ch. 4 of Peyton Jones, Wadler ”Implementation of Functional Programming Languages”, Prentice Hall, Englewood Cliffs (1987)
Field, A., Harrison, P.: Functional Programming. Addison-Wesley, Reading (1988)
Pettersson, M.: A term pattern-match compiler inspired by finite-automata theory. In: Pfahler, P., Kastens, U. (eds.) CC 1992. LNCS, vol. 641, Springer, Heidelberg (1992)
Scott, K., Ramsey, N.: When do match-compilation heuristics matter? Technical Report CS-2000-13, University of Virginia (2000)
Fessant, F.L., Maranget, L.: Optimizing pattern matching. In: ICFP, pp. 26–37 (2001)
Wadler, P.: Views: A way for pattern matching to cohabit with data abstraction. In: POPL (1987)
Okasaki, C.: Views for Standard ML. In: Proceedings of SIGPLAN Workshop on ML, pp. 14–23 (1998)
Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design Patterns. Addison-Wesley, Reading (1995)
Emir, B., Williams, J., Odersky, M.: Matching objects with patterns. In: ECOOP 2007. LNCS, vol. 4609, Springer, Heidelberg (2007)
Syme, D., Neverov, G., Margetson, J.: Extensible Pattern Matching via a Lightweight Language Extension. In: ICFP (2007)
Igarashi, A., Pierce, B., Wadler, P.: Featherweight Java. In: OOPSLA (1999)
Emir, B.: Object-Oriented Pattern Matching. PhD thesis, EPFL Lausanne (2007)
Leroy, X., Grall, H.: Coinductive big-step operational semantics. Theoretical Computer Science (submitted)
Ma, Q.: Concurrent Classes and Pattern Matching in the Join Calculus. PhD thesis, INRIA-Rocquencourt and University Paris 7 (2005)
Maranget, L.: Warnings in pattern matching. Journal of Functional Programming 17(3), 387–421 (2007)
Gostanza, P.P., Pena, R., Nunez, M.M.: A new look at pattern matching in abstract data types. In: ICFP (1996)
Zenger, M., Odersky, M.: Extensible algebraic datatypes with defaults. In: ICFP (2001)
Liu, J., Myers, A.C.: JMatch: Iterable Abstract Pattern Matching for Java. In: Dahl, V., Wadler, P. (eds.) PADL 2003. LNCS, vol. 2562, pp. 110–127. Springer, Heidelberg (2002)
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 2007 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Emir, B., Ma, Q., Odersky, M. (2007). Translation Correctness for First-Order Object-Oriented Pattern Matching. In: Shao, Z. (eds) Programming Languages and Systems. APLAS 2007. Lecture Notes in Computer Science, vol 4807. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-76637-7_5
Download citation
DOI: https://doi.org/10.1007/978-3-540-76637-7_5
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-76636-0
Online ISBN: 978-3-540-76637-7
eBook Packages: Computer ScienceComputer Science (R0)