skip to main content
research-article

Robust scripting via patterns

Published: 22 October 2012 Publication History

Abstract

Dynamic typing in scripting languages is a two-edged sword. On the one hand, it can be more flexible and more concise than static typing. On the other hand, it can lead to less robust code. We argue that patterns can give scripts much of the robustness of static typing, without losing the flexibility and concision of dynamic typing. To make this case, we describe a rich pattern system in the dynamic language Thorn. Thorn patterns interact with its control constructs and scoping rules to support concise and robust test-and-extract idioms. Thorn patterns encompass an extensive set of features from ML-style patterns to regular expressions and beyond. And Thorn patterns can be first-class and support pattern-punning (mirror constructor syntax). Overall, this paper describes a powerful pattern system that makes scripting more robust.

References

[1]
Bard Bloom, John Field, Nathaniel Nystrom, Johan Östlund, Gregor Richards, Rok Strnisa, Jan Vitek, and Tobias Wrigstad. Thorn: robust, concurrent, extensible scripting on the JVM. In Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), pages 117--136, October 2009.
[2]
R. M. Burstall, D. B. MacQueen, and D. T. Sannella. Hope: An experimental applicative language, 1980.
[3]
Burak Emir, Martin Odersky, and John Williams. Matching objects with patterns. In European Conference on Object-Oriented Programming (ECOOP), pages 273--298, 2007.
[4]
Michael D. Ernst, Craig S. Kaplan, and Craig Chambers. Predicate dispatching: A unified theory of dispatch. In European Conference for Object-Oriented Programming (ECOOP), pages 186--211, 1998.
[5]
David Flanagan and Yukihiro Matsumoto. The Ruby Programming Language. O'Reilly, 2008.
[6]
Felix Geller, Robert Hirschfeld, and Gilad Bracha. Pattern matching for an object-oriented dynamically typed programming language. Technical Report Hasso Plattner Institute Technical Report 36, University of Potsdam, 2010.
[7]
Ralph E. Griswold, J. F. Poage, and Ivan P. Polonsky. The SNOBOL 4 Programming Language. Prentice-Hall, Englewood Cliffs, NJ, 1968.
[8]
Martin Hirzel, Nathaniel Nystrom, Bard Bloom, and Jan Vitek. Matchete: Paths through the pattern matching jungle. In Practical Aspects of Declarative Languages (PADL), pages 150--166, 2008.
[9]
Paul Hudak, Simon L. Peyton Jones, Philip Wadler, Brian Boutel, Jon Fairbairn, Joseph H. Fasel, Marıa M. Guzmán, Kevin Hammond, John Hughes, Thomas Johnsson, Richard B. Kieburtz, Rishiyur S. Nikhil, Will Partain, and John Peterson. Report on the programming language Haskell, a non-strict, purely functional language. SIGPLAN Notices, 27(5):R1--R164, 1992.
[10]
Roberto Ierusalimschy. Programming in Lua. Lua.org, second edition, 2006.
[11]
Barry Jay and Delia Kesner. First-class patterns. Journal of Functional Programming (JFP), 19(02):191--225, 2009.
[12]
JetBrains. Kotlin language project page. http://confluence.jetbrains.net/display/Kotlin/.
[13]
P. J. Landin. The next 700 programming languages. Communications of the ACM (CACM), 9(3):157--166, March 1966.
[14]
Jed Liu and Andrew C. Myers. JMatch: Iterable abstract pattern matching for Java. In Practical Aspects of Declarative Languages (PADL), pages 273--298, 2003.
[15]
Robin Milner, Mads Tofte, Robert Harper, and David Macqueen. The Definition of Standard ML - Revised. The MIT Press, rev sub edition, May 1997.
[16]
Pierre-Etienne Moreau, Christophe Ringeissen, and Marian Vittek. A pattern matching compiler for multiple target languages. In International Conference on Compiler Construction (CC), 2003.
[17]
Chris Okasaki. Purely Functional Data Structures. Cambridge University Press, June 1999.
[18]
Python programming language -- official website. http://python.org/.
[19]
Don Syme, Gergory Neverov, and James Margetson. Extensible pattern matching via a lightweight language extension. In International Conference on Functional Programming (ICFP), pages 29--40, 2007.
[20]
Laurence Tratt. Domain specific language implementation via compile-time meta-programming. Transactions on Programming Languages and Systems (TOPLAS), 30(6), 2008.
[21]
P. Wadler. Views: a way for pattern matching to cohabit with data abstraction. In Proceedings of the 14th ACM SIGACT-SIGPLAN symposium on Principles of programming languages, POPL '87, pages 307--313, New York, NY, USA, 1987. ACM.
[22]
Larry Wall, Tom Christiansen, and Jon Orwant. Programming Perl. O'Reilly, third edition, 2000.
[23]
Alessandro Warth and Ian Piumarta. OMeta: An object-oriented language for pattern matching. In Dynamic Languages Symposium (DLS), pages 11--19, 2007.
[24]
Andrew K. Wright. Pattern matching for Scheme, 1996. The match special form is part of PLT Scheme's MzLib library.

Cited By

View all
  • (2020)Dynamic pattern matching with PythonProceedings of the 16th ACM SIGPLAN International Symposium on Dynamic Languages10.1145/3426422.3426983(85-98)Online publication date: 17-Nov-2020
  • (2015)Building the regional system for seismic data processing2015 International Conference on Information and Digital Technologies10.1109/DT.2015.7222981(261-265)Online publication date: Jul-2015
  • (2013)Open pattern matching for C++ACM SIGPLAN Notices10.1145/2637365.251722249:3(33-42)Online publication date: 27-Oct-2013
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM SIGPLAN Notices
ACM SIGPLAN Notices  Volume 48, Issue 2
DLS '12
February 2013
114 pages
ISSN:0362-1340
EISSN:1558-1160
DOI:10.1145/2480360
Issue’s Table of Contents
  • cover image ACM Conferences
    DLS '12: Proceedings of the 8th symposium on Dynamic languages
    October 2012
    128 pages
    ISBN:9781450315647
    DOI:10.1145/2384577
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: 22 October 2012
Published in SIGPLAN Volume 48, Issue 2

Check for updates

Author Tags

  1. deconstruction
  2. first-class patterns
  3. patterns

Qualifiers

  • Research-article

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)8
  • Downloads (Last 6 weeks)1
Reflects downloads up to 24 Oct 2024

Other Metrics

Citations

Cited By

View all
  • (2020)Dynamic pattern matching with PythonProceedings of the 16th ACM SIGPLAN International Symposium on Dynamic Languages10.1145/3426422.3426983(85-98)Online publication date: 17-Nov-2020
  • (2015)Building the regional system for seismic data processing2015 International Conference on Information and Digital Technologies10.1109/DT.2015.7222981(261-265)Online publication date: Jul-2015
  • (2013)Open pattern matching for C++ACM SIGPLAN Notices10.1145/2637365.251722249:3(33-42)Online publication date: 27-Oct-2013
  • (2013)Open pattern matching for C++Proceedings of the 12th international conference on Generative programming: concepts & experiences10.1145/2517208.2517222(33-42)Online publication date: 27-Oct-2013
  • (2013)Reconciling exhaustive pattern matching with objectsACM SIGPLAN Notices10.1145/2499370.246219448:6(343-354)Online publication date: 16-Jun-2013
  • (2013)Reconciling exhaustive pattern matching with objectsProceedings of the 34th ACM SIGPLAN Conference on Programming Language Design and Implementation10.1145/2491956.2462194(343-354)Online publication date: 16-Jun-2013
  • (2013)Flexible task-driven system for image processingThe International Conference on Digital Technologies 201310.1109/DT.2013.6566276(1-5)Online publication date: May-2013

View Options

Get Access

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media