Sound Type-Dependent Syntactic Language Extension

Journal Article (2016)
Author(s)

Florian Lorenzen (Technical University of Berlin)

S.T. Erdweg (Technische Universität Darmstadt, TU Delft - Programming Languages)

Research Group
Programming Languages
Copyright
© 2016 Florian Lorenzen, S.T. Erdweg
DOI related publication
https://doi.org/10.1145/2837614.2837644
More Info
expand_more
Publication Year
2016
Language
English
Copyright
© 2016 Florian Lorenzen, S.T. Erdweg
Research Group
Programming Languages
Issue number
1
Volume number
51
Pages (from-to)
204-216
Reuse Rights

Other than for strictly personal use, it is not permitted to download, forward or distribute the text or part of it, without the consent of the author(s) and/or copyright holder(s), unless the work is under an open content license such as Creative Commons.

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.

Files

Soundx_popl16.pdf
(pdf | 0.288 Mb)
License info not available