skip to main content
research-article

Patterns as objects in grace

Authors Info & Claims
Published:22 October 2012Publication History
Skip Abstract Section

Abstract

Object orientation and pattern matching are often seen as conflicting approaches to program design. Object-oriented programs place type-dependent behavior inside objects and invoke it via dynamic dispatch, while pattern-matching programs place type-dependent behavior outside data structures and invoke it via multiway conditionals (case statements).

Grace is a new, dynamic, object-oriented language designed to support teaching: to this end, Grace needs to support both styles. We explain how this conflict can be resolved gracefully: by modelling patterns and cases as partial functions, reifying those functions as objects, and then building up complex patterns from simpler ones using pattern combinators. We describe the implementation of this design as an object-oriented framework, and a case study of its effectiveness.

Skip Supplemental Material Section

Supplemental Material

References

  1. A. P. Black, K. B. Bruce, M. Homer, and J. Noble. Grace: the absence of (inessential) difficulty. In Onward!, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. B. Bloom1, J. Field, N. Nystrom, J. Östlund, G. Richards, R. Strnisa, J. Vitek, and T. Wrigstad. Thorn--robust, concurrent, extensible scripting on the JVM. In OOPSLA, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. M. Blume, U. A. Acar, and W. Chae. Extensible programming with first-class cases. In ICFP, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. B. Emir, M. Odersky, and J. Williams. Matching objects with patterns. In ECOOP, pages 273--298, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. E. Gamma, R. Helm, R. E. Johnson, and J. Vlissides. Design Patterns. Addison-Wesley, 1994.Google ScholarGoogle Scholar
  6. F. Geller, R. Hirschfeld, and G. Bracha. Pattern matching for an object-oriented and dynamically typed programming language. Technical Report 36, Hasso-Plattner-Instituts für Sofwaresystemtechnik an der Universitat Potsdam, 2010.Google ScholarGoogle Scholar
  7. A. Goldberg and D. Robson.Google ScholarGoogle Scholar

Index Terms

  1. Patterns as objects in grace

      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

      Full Access

      • 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

        Copyright © 2012 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 22 October 2012

        Check for updates

        Qualifiers

        • research-article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!