Skip to main content

Translation Correctness for First-Order Object-Oriented Pattern Matching

  • Conference paper

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 4807))

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

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Burstall, R.M.: Proving properties of programs by inductive definitions. Computer 41–48 (1969)

    Google Scholar 

  2. Wadler, P.: Pattern Matching. In: ch. 4 of Peyton Jones, Wadler ”Implementation of Functional Programming Languages”, Prentice Hall, Englewood Cliffs (1987)

    Google Scholar 

  3. Field, A., Harrison, P.: Functional Programming. Addison-Wesley, Reading (1988)

    MATH  Google Scholar 

  4. 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)

    Google Scholar 

  5. Scott, K., Ramsey, N.: When do match-compilation heuristics matter? Technical Report CS-2000-13, University of Virginia (2000)

    Google Scholar 

  6. Fessant, F.L., Maranget, L.: Optimizing pattern matching. In: ICFP, pp. 26–37 (2001)

    Google Scholar 

  7. Wadler, P.: Views: A way for pattern matching to cohabit with data abstraction. In: POPL (1987)

    Google Scholar 

  8. Okasaki, C.: Views for Standard ML. In: Proceedings of SIGPLAN Workshop on ML, pp. 14–23 (1998)

    Google Scholar 

  9. Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design Patterns. Addison-Wesley, Reading (1995)

    Google Scholar 

  10. Emir, B., Williams, J., Odersky, M.: Matching objects with patterns. In: ECOOP 2007. LNCS, vol. 4609, Springer, Heidelberg (2007)

    Chapter  Google Scholar 

  11. Syme, D., Neverov, G., Margetson, J.: Extensible Pattern Matching via a Lightweight Language Extension. In: ICFP (2007)

    Google Scholar 

  12. Igarashi, A., Pierce, B., Wadler, P.: Featherweight Java. In: OOPSLA (1999)

    Google Scholar 

  13. Emir, B.: Object-Oriented Pattern Matching. PhD thesis, EPFL Lausanne (2007)

    Google Scholar 

  14. Leroy, X., Grall, H.: Coinductive big-step operational semantics. Theoretical Computer Science (submitted)

    Google Scholar 

  15. Ma, Q.: Concurrent Classes and Pattern Matching in the Join Calculus. PhD thesis, INRIA-Rocquencourt and University Paris 7 (2005)

    Google Scholar 

  16. Maranget, L.: Warnings in pattern matching. Journal of Functional Programming 17(3), 387–421 (2007)

    Article  MATH  MathSciNet  Google Scholar 

  17. Gostanza, P.P., Pena, R., Nunez, M.M.: A new look at pattern matching in abstract data types. In: ICFP (1996)

    Google Scholar 

  18. Zenger, M., Odersky, M.: Extensible algebraic datatypes with defaults. In: ICFP (2001)

    Google Scholar 

  19. 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)

    Chapter  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Zhong Shao

Rights and permissions

Reprints 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)

Publish with us

Policies and ethics