skip to main content
10.1145/2491956.2462194acmconferencesArticle/Chapter ViewAbstractPublication PagespldiConference Proceedingsconference-collections
research-article

Reconciling exhaustive pattern matching with objects

Published:16 June 2013Publication History

ABSTRACT

Pattern matching, an important feature of functional languages, is in conflict with data abstraction and extensibility, which are central to object-oriented languages. Modal abstraction offers an integration of deep pattern matching and convenient iteration abstractions into an object-oriented setting; however, because of data abstraction, it is challenging for a compiler to statically verify properties such as exhaustiveness. In this work, we extend modal abstraction in the JMatch language to support static, modular reasoning about exhaustiveness and redundancy. New matching specifications allow these properties to be checked using an SMT solver. We also introduce expressive pattern-matching constructs. Our evaluation shows that these new features enable more concise code and that the performance of checking exhaustiveness and redundancy is acceptable.

References

  1. Bard Bloom and Martin J. Hirzel. Robust scripting via patterns. In Proc. 8th symposium on Dynamic languages (DLS), pp. 29--40, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Aaron Bohannon, J. Nathan Foster, Benjamin C. Pierce, Alexandre Pilkiewicz, and Alan Schmitt. Boomerang: Resourceful lenses for string data. In Proc. 35th ACM Symposium on Principles of Programming Languages (POPL), pp. 407--419, January 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Leonardo de Moura and Nikolaj Bjørner. Z3: an efficient SMT solver. In Proceedings of the Theory and Practice of Software, 14th Int'l Conf. on Tools and Algorithms for the Construction and Analysis of Systems, pp. 337--340, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Mirco Dotta, Philippe Suter, and Viktor Kuncak. On static analysis for expressive pattern matching. Technical report, École Polytechnique Fédérale de Lausanne, February 2008.Google ScholarGoogle Scholar
  5. Burak Emir, Martin Odersky, and John Williams. Matching objects with patterns. In Erik Ernst, editor, Proc. 21st European Conf. on Object-Oriented Programming, volume 4609 of Lecture Notes in Computer Science, pp. 273--298. Springer Berlin Heidelberg, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Michael Ernst, Craig Kaplan, and Craig Chambers. Predicate dispatching: A unified theory of dispatch. In Proc. 12th European Conf. on Object-Oriented Programming, pp. 186--211, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. J. Nathan Foster, Michael B. Greenwald, Jonathan T. Moore, Benjamin C. Pierce, and Alan Schmitt. Combinators for bidirectional tree transformations: A linguistic approach to the view-update problem. ACM Trans. Program. Lang. Syst., 29(3), May 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Jacques Garrigue. Typing deep pattern-matching in presence of polymorphic variants. In JSSST Workshop on Programming and Programming Languages, 2004.Google ScholarGoogle Scholar
  9. Ralph E. Griswold, David R. Hanson, and John T. Korb. Generators in Icon. ACM Transaction on Programming Languages and Systems, 3(2):144--161, April 1981. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Martin Hirzel, Nathaniel Nystrom, Bard Bloom, and Jan Vitek. Matchete: Paths through the pattern matching jungle. In Proc. 10th Int'l Conf. on Practical Aspects of Declarative Languages, pp. 150--166, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Chinawat Isradisaikul and Andrew C. Myers. Reconciling exhaustive pattern matching with objects. Technical report, Computing and Information Science, Cornell University, March 2013. http://hdl.handle.net/1813/33123.Google ScholarGoogle Scholar
  12. Richard E. Korf. Depth-first iterative-deepening: an optimal admissible tree search. Artificial Intelligence, 27(1):97--109, September 1985. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Fabrice Le Fessant and Luc Maranget. Optimizing pattern matching. In Proc. 6th ACM SIGPLAN Int'l Conf. on Functional Programming, pp. 26--37, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Gary T. Leavens and Peter Müller. Information hiding and visibility in interface specifications. In Proc. 33rd Int'l Conf. on Software Engineering (ICSE), pp. 385--395, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Keunwoo Lee, Anthony LaMarca, and Craig Chambers. HydroJ: object-oriented pattern matching for evolvable distributed systems. In Proc. 18th ACM SIGPLAN Conf. on Object-Oriented Programming, Systems, Languages and Applications, pp. 205--223, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Barbara Liskov, Russell Atkinson, Toby Bloom, J. Eliot Moss, J. Craig Schaffert, Robert Scheifler, and Alan Snyder. CLU Reference Manual. Springer-Verlag, 1984. Also published as Lecture Notes in Computer Science 114, G. Goos and J. Hartmanis, Eds., Springer-Verlag, 1981. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Jed Liu, Aaron Kimball, and Andrew C. Myers. Interruptible iterators. In Proc. 33rd ACM Symposium on Principles of Programming Languages (POPL), pp. 283--294, January 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Jed Liu and Andrew C. Myers. JMatch: Java plus pattern matching. Technical Report TR2002--1878, Computer Science Department, Cornell University, October 2002. Software release at http://www.cs.cornell.edu/projects/jmatch.Google ScholarGoogle Scholar
  19. Jed Liu and Andrew C. Myers. JMatch: Iterable abstract pattern matching for Java. In Proc. 5th International Symposium on Practical Aspects of Declarative Languages, pp. 110--127, January 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Todd Millstein. Practical predicate dispatch. In Proc. 19th ACM SIGPLAN Conf. on Object-Oriented Programming, Systems, Languages and Applications, pp. 345--364, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Andrew C. Myers, Barbara Liskov, and Nicholas Mathewson. PolyJ: Parameterized types for Java. Software release, at http://www.cs.cornell.edu/polyj, July 1998.Google ScholarGoogle Scholar
  22. Martin Odersky, Lex Spoon, and Bill Venners. Programming in Scala: A Comprehensive Step-by-step Guide. Artima Incorporation, USA, 1st edition, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Martin Odersky and Philip Wadler. Pizza into Java: translating theory into practice. In Proc. 24th ACM Symposium on Principles of Programming Languages (POPL), pp. 146--159, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Adam Richard and Ond\vrej Lhoták. OOMatch: pattern matching as dispatch in Java. In Companion 22nd ACM SIGPLAN Conf. on Object-Oriented Programming, Systems, Languages and Applications, pp. 771--772, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Clyde Ruby and Gary T. Leavens. Safely creating correct subclasses without seeing superclass code. In Proc. 15th ACM SIGPLAN Conf. on Object-Oriented Programming, Systems, Languages and Applications, pp. 208--228, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Zoltan Somogyi, Fergus Henderson, and Thomas Conway. The execution algorithm of Mercury, an efficient purely declarative logic programming language. The Journal of Logic Programming, 29(1--3):17--64, October--December 1996.Google ScholarGoogle ScholarCross RefCross Ref
  27. Philippe Suter, Mirco Dotta, and Viktor Kuncak. Decision procedures for algebraic data types with abstractions. In Proc. 37th ACM Symposium on Principles of Programming Languages (POPL), pp. 199--210, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Philippe Suter, Ali Sinan Köksal, and Viktor Kuncak. Satisfiability modulo recursive programs. In Proc. 18th Int'l Conf. on Static Analysis, pp. 298--315, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Don Syme, Gregory Neverov, and James Margetson. Extensible pattern matching via a lightweight language extension. In Proc. 12th ACM SIGPLAN Int'l Conf. on Functional Programming, pp. 29--40, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Philip Wadler. Views: a way for pattern matching to cohabit with data abstraction. In Proc. 14th ACM Symposium on Principles of Programming Languages (POPL), pp. 307--313, 1987. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Meng Wang, Jeremy Gibbons, Kazutaka Matsuda, and Zhenjiang Hu. Refactoring pattern matching. Science of Computer Programming, in press. Available online 24 August 2012.Google ScholarGoogle Scholar
  32. Matthias Zenger and Martin Odersky. Extensible algebraic datatypes with defaults. In Proc. 6th ACM SIGPLAN Int'l Conf. on Functional Programming, pp. 241--252, September 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Reconciling exhaustive pattern matching with objects

            Recommendations

            Comments

            Login options

            Check if you have access through your login credentials or your institution to get full access on this article.

            Sign in
            • Published in

              cover image ACM Conferences
              PLDI '13: Proceedings of the 34th ACM SIGPLAN Conference on Programming Language Design and Implementation
              June 2013
              546 pages
              ISBN:9781450320146
              DOI:10.1145/2491956
              • cover image ACM SIGPLAN Notices
                ACM SIGPLAN Notices  Volume 48, Issue 6
                PLDI '13
                June 2013
                515 pages
                ISSN:0362-1340
                EISSN:1558-1160
                DOI:10.1145/2499370
                Issue’s Table of Contents

              Copyright © 2013 ACM

              Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

              Publisher

              Association for Computing Machinery

              New York, NY, United States

              Publication History

              • Published: 16 June 2013

              Permissions

              Request permissions about this article.

              Request Permissions

              Check for updates

              Qualifiers

              • research-article

              Acceptance Rates

              PLDI '13 Paper Acceptance Rate46of267submissions,17%Overall Acceptance Rate406of2,067submissions,20%

              Upcoming Conference

              PLDI '24

            PDF Format

            View or Download as a PDF file.

            PDF

            eReader

            View online with eReader.

            eReader