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.
- Bard Bloom and Martin J. Hirzel. Robust scripting via patterns. In Proc. 8th symposium on Dynamic languages (DLS), pp. 29--40, 2012. Google ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 Scholar
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- Jacques Garrigue. Typing deep pattern-matching in presence of polymorphic variants. In JSSST Workshop on Programming and Programming Languages, 2004.Google Scholar
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 Scholar
- Richard E. Korf. Depth-first iterative-deepening: an optimal admissible tree search. Artificial Intelligence, 27(1):97--109, September 1985. Google ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 Scholar
- 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 ScholarDigital Library
- Todd Millstein. Practical predicate dispatch. In Proc. 19th ACM SIGPLAN Conf. on Object-Oriented Programming, Systems, Languages and Applications, pp. 345--364, 2004. Google ScholarDigital Library
- 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 Scholar
- Martin Odersky, Lex Spoon, and Bill Venners. Programming in Scala: A Comprehensive Step-by-step Guide. Artima Incorporation, USA, 1st edition, 2008. Google ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarCross Ref
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- Meng Wang, Jeremy Gibbons, Kazutaka Matsuda, and Zhenjiang Hu. Refactoring pattern matching. Science of Computer Programming, in press. Available online 24 August 2012.Google Scholar
- 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 ScholarDigital Library
Index Terms
- Reconciling exhaustive pattern matching with objects
Recommendations
Reconciling exhaustive pattern matching with objects
PLDI '13Pattern 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 ...
Formal validation of pattern matching code
PPDP '05: Proceedings of the 7th ACM SIGPLAN international conference on Principles and practice of declarative programmingWhen addressing the formal validation of generated software, two main alternatives consist either to prove the correctness of compilers or to directly validate the generated code. Here, we focus on directly proving the correctness of compiled code ...
Interruptible iterators
POPL '06: Conference record of the 33rd ACM SIGPLAN-SIGACT symposium on Principles of programming languagesThis paper introduces interruptible iterators, a language feature that makes expressive iteration abstractions much easier to implement. Iteration abstractions are valuable for software design, as shown by their frequent use in well-designed data ...
Comments