skip to main content
research-article

Modular interpreters for the masses: implicit context propagation using object algebras

Published:26 October 2015Publication History
Skip Abstract Section

Abstract

Modular interpreters have the potential to achieve component-based language development: instead of writing language interpreters from scratch, they can be assembled from reusable, semantic building blocks. Unfortunately, traditional language interpreters are hard to extend because different language constructs may require different interpreter signatures. For instance, arithmetic interpreters produce a value without any context information, whereas binding constructs require an additional environment. In this paper, we present a practical solution to this problem based on implicit context propagation. By structuring denotational-style interpreters as Object Algebras, base interpreters can be retroactively lifted into new interpreters that have an extended signature. The additional parameters are implicitly propagated behind the scenes, through the evaluation of the base interpreter. Interpreter lifting enables a flexible style of component-based language development. The technique works in mainstream object-oriented languages, does not sacrifice type safety or separate compilation, and can be easily automated. We illustrate implicit context propagation using a modular definition of Featherweight Java and its extension to support side-effects.

References

  1. L. Allison. Direct semantics and exceptions define jumps and coroutines. Information Processing Letters, 31(6):327–330, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. E. Burmako. Scala macros: Let our powers combine!: On how rich syntax and static types work with metaprogramming. In SCALA, pages 3:1–3:10. ACM, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. R. Cartwright and M. Felleisen. Extensible denotational language specifications. In Theoretical Aspects of Computer Software, pages 244–272. Springer, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. M. Churchill, P. D. Mosses, N. Sculthorpe, and P. Torrini. Reusable components of semantic specifications. In Transactions on Aspect-Oriented Software Development XII, pages 132–179. Springer, 2015.Google ScholarGoogle Scholar
  5. T. Cleenewerck. Component-based DSL development. In GPCE, pages 245–264. Springer, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. T. Cleenewerck. Modularizing Language Constructs: A Reflective Approach. PhD thesis, Vrije Universteit Brussel, 2007.Google ScholarGoogle Scholar
  7. P. Costanza. Dynamically scoped functions as the essence of AOP. ACM SIGPLAN Notices, 38(8):29–36, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. L. Duponcheel. Using catamorphisms, subtypes and monad transformers for writing modular functional interpreters. 1995. URL http://citeseerx.ist.psu.edu/viewdoc/download?doi=10. 1.1.11.7093.Google ScholarGoogle Scholar
  9. D. Espinosa. Semantic Lego. PhD thesis, Columbia University, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. M. Flatt, S. Krishnamurthi, and M. Felleisen. Classes and mixins. In POPL, pages 171–183. ACM, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. M. Gouseti, C. Peters, and T. v. d. Storm. Extensible language implementation with Object Algebras (short paper). In GPCE, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. P. Haller and M. Odersky. Scala Actors: Unifying thread-based and event-based programming. Theoretical Computer Science, 410(2-3): 202–220, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. L. T. Hansen. Syntax for dynamic scoping, 2000. URL http: //srfi.schemers.org/srfi-15/srfi-15.html. SRFI-15.Google ScholarGoogle Scholar
  14. D. R. Hanson and T. A. Proebsting. Dynamic variables. ACM SIGPLAN Notices, 36(5):264–273, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. J. Harm, R. Lämmel, and G. Riedewald. The language development laboratory (LDL). In Selected papers from the 8th Nordic Workshop on Programming Theory (NWPT’96), pages 77–86, 1997.Google ScholarGoogle Scholar
  16. J. Heering and P. Klint. Semantics of programming languages: A tool-oriented approach. SIGPLAN Notices, 35(3):39–48, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. R. Hirschfeld, P. Costanza, and O. Nierstrasz. Context-oriented programming. Journal of Object Technology, 7(3), 2008.Google ScholarGoogle ScholarCross RefCross Ref
  18. A. Igarashi, B. Pierce, and P. Wadler. Featherweight Java: A minimal core calculus for Java and GJ. In OOPSLA, pages 132–146. ACM, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. U. Kastens. The GAG-system: A tool for compiler construction. 1984. URL http://digital.ub.uni-paderborn.de/hs/ download/pdf/41963.Google ScholarGoogle Scholar
  20. O. Kiselyov, A. Sabry, and C. Swords. Extensible effects: an alternative to monad transformers. ACM SIGPLAN Notices, 48(12):59–70, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. D. Leijen. Extensible records with scoped labels. Trends in Functional Programming, 5:297–312, 2005.Google ScholarGoogle Scholar
  22. J. R. Lewis, J. Launchbury, E. Meijer, and M. B. Shields. Implicit parameters: Dynamic scoping with static types. In POPL, pages 108– 118. ACM, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. S. Liang, P. Hudak, and M. Jones. Monad transformers and modular interpreters. In POPL, pages 333–343. ACM, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. P. D. Mosses and M. J. New. Implicit propagation in structural operational semantics. Electronic Notes in Theoretical Computer Science, 229(4):49–66, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. B. C. d. S. Oliveira and W. R. Cook. Extensibility for the masses: practical extensibility with Object Algebras. In ECOOP, pages 2–27. Springer, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. G. L. Steele Jr. Building interpreters by composing monads. In POPL’94, pages 472–492. ACM, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. V. Vergu, P. Neron, and E. Visser. DynSem: A DSL for dynamic semantics specification. In RTA, LIPICS, 2015.Google ScholarGoogle Scholar
  28. E. Visser. Scoped dynamic rewrite rules. Electronic Notes in Theoretical Computer Science, 59(4):375–396, 2001.Google ScholarGoogle ScholarCross RefCross Ref
  29. M. P. Ward. Language-oriented programming. Software-Concepts and Tools, 15(4):147–161, 1994.Google ScholarGoogle Scholar

Index Terms

  1. Modular interpreters for the masses: implicit context propagation using object algebras

    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 51, Issue 3
      GPCE '15
      March 2016
      184 pages
      ISSN:0362-1340
      EISSN:1558-1160
      DOI:10.1145/2936314
      • Editor:
      • Andy Gill
      Issue’s Table of Contents
      • cover image ACM Conferences
        GPCE 2015: Proceedings of the 2015 ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences
        October 2015
        184 pages
        ISBN:9781450336871
        DOI:10.1145/2814204

      Copyright © 2015 ACM

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 26 October 2015

      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!