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.
- L. Allison. Direct semantics and exceptions define jumps and coroutines. Information Processing Letters, 31(6):327–330, 1989. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- R. Cartwright and M. Felleisen. Extensible denotational language specifications. In Theoretical Aspects of Computer Software, pages 244–272. Springer, 1994. Google Scholar
Digital Library
- 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 Scholar
- T. Cleenewerck. Component-based DSL development. In GPCE, pages 245–264. Springer, 2003. Google Scholar
Digital Library
- T. Cleenewerck. Modularizing Language Constructs: A Reflective Approach. PhD thesis, Vrije Universteit Brussel, 2007.Google Scholar
- P. Costanza. Dynamically scoped functions as the essence of AOP. ACM SIGPLAN Notices, 38(8):29–36, 2003. Google Scholar
Digital Library
- 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 Scholar
- D. Espinosa. Semantic Lego. PhD thesis, Columbia University, 1995. Google Scholar
Digital Library
- M. Flatt, S. Krishnamurthi, and M. Felleisen. Classes and mixins. In POPL, pages 171–183. ACM, 1998. Google Scholar
Digital Library
- M. Gouseti, C. Peters, and T. v. d. Storm. Extensible language implementation with Object Algebras (short paper). In GPCE, 2014. Google Scholar
Digital Library
- P. Haller and M. Odersky. Scala Actors: Unifying thread-based and event-based programming. Theoretical Computer Science, 410(2-3): 202–220, 2009. Google Scholar
Digital Library
- L. T. Hansen. Syntax for dynamic scoping, 2000. URL http: //srfi.schemers.org/srfi-15/srfi-15.html. SRFI-15.Google Scholar
- D. R. Hanson and T. A. Proebsting. Dynamic variables. ACM SIGPLAN Notices, 36(5):264–273, 2001. Google Scholar
Digital Library
- 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 Scholar
- J. Heering and P. Klint. Semantics of programming languages: A tool-oriented approach. SIGPLAN Notices, 35(3):39–48, 2000. Google Scholar
Digital Library
- R. Hirschfeld, P. Costanza, and O. Nierstrasz. Context-oriented programming. Journal of Object Technology, 7(3), 2008.Google Scholar
Cross Ref
- 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 Scholar
Digital Library
- U. Kastens. The GAG-system: A tool for compiler construction. 1984. URL http://digital.ub.uni-paderborn.de/hs/ download/pdf/41963.Google Scholar
- O. Kiselyov, A. Sabry, and C. Swords. Extensible effects: an alternative to monad transformers. ACM SIGPLAN Notices, 48(12):59–70, 2013. Google Scholar
Digital Library
- D. Leijen. Extensible records with scoped labels. Trends in Functional Programming, 5:297–312, 2005.Google Scholar
- 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 Scholar
Digital Library
- S. Liang, P. Hudak, and M. Jones. Monad transformers and modular interpreters. In POPL, pages 333–343. ACM, 1995. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- G. L. Steele Jr. Building interpreters by composing monads. In POPL’94, pages 472–492. ACM, 1994. Google Scholar
Digital Library
- V. Vergu, P. Neron, and E. Visser. DynSem: A DSL for dynamic semantics specification. In RTA, LIPICS, 2015.Google Scholar
- E. Visser. Scoped dynamic rewrite rules. Electronic Notes in Theoretical Computer Science, 59(4):375–396, 2001.Google Scholar
Cross Ref
- M. P. Ward. Language-oriented programming. Software-Concepts and Tools, 15(4):147–161, 1994.Google Scholar
Index Terms
Modular interpreters for the masses: implicit context propagation using object algebras
Recommendations
Modular interpreters for the masses: implicit context propagation using object algebras
GPCE 2015: Proceedings of the 2015 ACM SIGPLAN International Conference on Generative Programming: Concepts and ExperiencesModular 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 ...
From object algebras to attribute grammars
OOPSLA '14Oliveira and Cook (2012) and Oliveira et al. (2013) have recently introduced object algebras as a program structuring technique to improve the modularity and extensibility of programs. We analyze the relationship between object algebras and attribute ...
Scrap your boilerplate with object algebras
OOPSLA 2015: Proceedings of the 2015 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and ApplicationsTraversing complex Abstract Syntax Trees (ASTs) typically requires large amounts of tedious boilerplate code. For many operations most of the code simply walks the structure, and only a small portion of the code implements the functionality that ...






Comments