Abstract
Syntactic language extensions can introduce new facilities into a programming language while requiring little implementation effort and modest changes to the compiler. It is typical to desugar language extensions in a distinguished compiler phase after parsing or type checking, not affecting any of the later compiler phases. If desugaring happens before type checking, the desugaring cannot depend on typing information and type errors are reported in terms of the generated code. If desugaring happens after type checking, the code generated by the desugaring is not type checked and may introduce vulnerabilities. Both options are undesirable. We propose a system for syntactic extensibility where desugaring happens after type checking and desugarings are guaranteed to only generate well-typed code. A major novelty of our work is that desugarings operate on typing derivations instead of plain syntax trees. This provides desugarings access to typing information and forms the basis for the soundness guarantee we provide, namely that a desugaring generates a valid typing derivation. We have implemented our system for syntactic extensibility in a language-independent fashion and instantiated it for a substantial subset of Java, including generics and inheritance. We provide a sound Java extension for Scala-like for-comprehensions.
- E. Burmako. Scala macros: Let our powers combine!: On how rich syntax and static types work with metaprogramming. In Proceedings of the 4th Workshop on Scala, SCALA ’13, pages 3:1–3:10. ACM, 2013. Google Scholar
Digital Library
- A. Charguéraud. The locally nameless representation. Journal of Automated Reasoning, 49(3):363–408, 2012.Google Scholar
Cross Ref
- J. Cheney and C. Urban. Nominal logic programming. ACM Transactions on Programming Languages and Systems, 30(5):26:1–26:47, Sept. 2008. Google Scholar
Digital Library
- R. Cox, T. Bergan, A. T. Clements, F. Kaashoek, and E. Kohler. Xoc, an extension-oriented compiler for systems programming. In Proceedings of the 13th International Conference on Architectural Support for Programming Languages and Operating Systems, ASPLOS XIII, pages 244–254. ACM, 2008. Google Scholar
Digital Library
- D. de Rauglaudre. Camlp4 reference manual, 2003.Google Scholar
- S. Erdweg, T. Rendel, C. Kästner, and K. Ostermann. SugarJ: librarybased syntactic language extensibility. In Proceedings of the 2011 ACM International Conference on Object-oriented Programming, Systems, Languages, and Applications, OOPSLA ’11, pages 391–406. ACM, 2011. Google Scholar
Digital Library
- S. Erdweg, P. G. Giarrusso, and T. Rendel. Language composition untangled. In Proceedings of the Twelfth Workshop on Language Descriptions, Tools, and Applications, LDTA ’12, pages 7:1–7:8. ACM, 2012. Google Scholar
Digital Library
- M. Felleisen, R. B. Findler, and M. Flatt. Semantics Engineering with PLT Redex. MIT Press, 2009. Google Scholar
Digital Library
- D. Fisher and O. Shivers. Building language towers with Ziggurat. Journal of Functional Programming, 18(5–6):707–780, Sept. 2008. Google Scholar
Digital Library
- M. Flatt. Creating languages in Racket. Communications of the ACM, 55(1):48–56, Jan. 2012. Google Scholar
Digital Library
- S. Ganz, A. Sabry, and W. Taha. Macros as multi-stage computations: Type-safe, generative, binding macros in MacroML. In Proceedings of the 6th ACM SIGPLAN International Conference on Functional Programming, ICFP ’01, pages 74–85. ACM, 2001. Google Scholar
Digital Library
- G. Giorgidze and H. Nilsson. Embedding a functional hybrid modelling language in Haskell. In Proceedings of the 20th International Conference on Implementation and Application of Functional Languages, IFL ’08, pages 138–155. Springer, 2008. Google Scholar
Digital Library
- J. Gosling, B. Joy, G. L. Steele, Jr., G. Bracha, and A. Buckley. The Java R Language Specification – Java SE 8 Edition. Oracle America, Inc., 2014. Google Scholar
Digital Library
- S. Grewe, S. Erdweg, P. Wittmann, and M. Mezini. Type systems for the masses: Deriving soundness proofs and e fficient checkers. In Proceedings of Symposium on New Ideas, New Paradigms, and Reflections on Programming and Software, Onward! 2015. ACM, 2015. Google Scholar
Digital Library
- to appear.Google Scholar
- R. Harper. Practical Foundations for Programming Languages. Cambridge University Press, 2013. Google Scholar
Digital Library
- R. Harper and D. R. Licata. Mechanizing metatheory in a logical framework. Journal of Functional Programming, 17(4-5):613–673, July 2007. Google Scholar
Digital Library
- D. Herman. A Theory of Typed Hygienic Macros. PhD thesis, Northeastern University, Boston, Massachusetts, 2010. Google Scholar
Digital Library
- F. Lorenzen and S. Erdweg. Modular and automated type-soundness verification for language extensions. In Proceedings of 18th International Conference on Functional Programming, ICFP ’13, pages 331–342. ACM, 2013. Google Scholar
Digital Library
- G. Mainland. Why it’s nice to be quoted: quasiquoting for Haskell. In Proceedings of the ACM SIGPLAN Workshop on Haskell, Haskell ’07, pages 73–82. ACM, 2007. Google Scholar
Digital Library
- G. Mainland. Explicitly heterogeneous metaprogramming with metahaskell. In Proceedings of the 17th ACM SIGPLAN International Conference on Functional Programming, ICFP ’12, pages 311–322. ACM, 2012. Google Scholar
Digital Library
- Marlow, Simon. Haskell 2010 – language report, June 2010.Google Scholar
- M. Odersky, L. Spoon, and B. Venners. Programming in Scala: A Comprehensive Step-by-step Guide. Artima Incorporation, 2008. Google Scholar
Digital Library
- C. Omar, D. Kurilova, L. Nistor, B. Chung, A. Potanin, and J. Aldrich. Safely composable type-specific languages. In R. Jones, editor, ECOOP 2014 – Object-Oriented Programming, volume 8586 of Lecture Notes in Computer Science, pages 105–130. Springer, 2014.Google Scholar
Digital Library
- B. C. Pierce. Types and Programming Languages. MIT Press, 2002. Google Scholar
Digital Library
- C. Schürmann and F. Pfenning. Automated theorem proving in a simple meta-logic for LF. In Proceedings of International Conference on Automated Deduction, volume 1421 of LNCS, pages 286–300. Springer, 1998. Google Scholar
Digital Library
- T. Sheard and S. L. Peyton Jones. Template metaprogramming for Haskell. In Proceedings of the ACM Workshop on Haskell, Haskell ’02, pages 1–16. ACM, 2002. Google Scholar
Digital Library
- M. R. Shinwell, A. M. Pitts, and M. J. Gabbay. FreshML: Programming with binders made simple. In Proceedings of the 8th ACM SIGPLAN International Conference on Functional Programming, ICFP ’03, pages 263–274. ACM, Aug. 2003. Google Scholar
Digital Library
- P. Stansifer and M. Wand. Romeo: A system for more flexible binding-safe programming. In Proceedings of the 19th ACM SIGPLAN International Conference on Functional Programming, ICFP ’14, pages 53–65. ACM, 2014. Google Scholar
Digital Library
- E. Visser. Syntax Definition for Language Prototyping. PhD thesis, University of Amsterdam, 1997.Google Scholar
- E. Visser, Z.-E.-A. Benaissa, and A. Tolmach. Building program optimizers with rewriting strategies. In Proceedings of the 3rd ACM SIGPLAN International Conference on Functional Programming, ICFP ’98, pages 13–26. ACM, 1998. Google Scholar
Digital Library
- H. Xi and C. Schürmann. CPS transform for Dependent ML (abstract). Logic Journal of IGPL, 9(5):739–754, Sept. 2001.Google Scholar
Index Terms
Sound type-dependent syntactic language extension
Recommendations
Sound type-dependent syntactic language extension
POPL '16: Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming LanguagesSyntactic language extensions can introduce new facilities into a programming language while requiring little implementation effort and modest changes to the compiler. It is typical to desugar language extensions in a distinguished compiler phase after ...
Modular and automated type-soundness verification for language extensions
ICFP '13Language extensions introduce high-level programming constructs that protect programmers from low-level details and repetitive tasks. For such an abstraction barrier to be sustainable, it is important that no errors are reported in terms of generated ...
Modular and automated type-soundness verification for language extensions
ICFP '13: Proceedings of the 18th ACM SIGPLAN international conference on Functional programmingLanguage extensions introduce high-level programming constructs that protect programmers from low-level details and repetitive tasks. For such an abstraction barrier to be sustainable, it is important that no errors are reported in terms of generated ...






Comments