Abstract
Syntactic sugar is pervasive in language technology. It is used to shrink the size of a core language; to define domain-specific languages; and even to let programmers extend their language. Unfortunately, syntactic sugar is eliminated by transformation, so the resulting programs become unfamiliar to authors. Thus, it comes at a price: it obscures the relationship between the user's source program and the program being evaluated.
We address this problem by showing how to compute reduction steps in terms of the surface syntax. Each step in the surface language emulates one or more steps in the core language. The computed steps hide the transformation, thus maintaining the abstraction provided by the surface language. We make these statements about emulation and abstraction precise, prove that they hold in our formalism, and verify part of the system in Coq. We have implemented this work and applied it to three very different languages.
- A. Aiken and B. R. Murphy. Implementing regular tree expressions. In Conference on Functional Programming Languages and Computer Architecture, 1991. Google Scholar
Digital Library
- A. Bohannon, J. N. Foster, B. C. Pierce, A. Pilkiewicz, and A. Schmitt. Boomerang: Resourceful lenses for string data. In Principles of Programming Languages, 2008. Google Scholar
Digital Library
- M. Bravenboer, K. T. Kalleberg, R. Vermaas, and E. Visser. Stratego/XT 0.17. A language and toolset for program transformation. Science of Computer Programming, 72(1--2), 2008. Google Scholar
Digital Library
- J. Clements. Portable and high-level access to the stack with Continuation Marks. PhD thesis, Northeastern University, 2006.Google Scholar
- J. Clements, M. Flatt, and M. Felleisen. Modeling an algebraic stepper. In European Symposium on Programming Languages and Systems, 2001. Google Scholar
Digital Library
- R. Culpepper and M. Felleisen. Fortifying macros. In International Conference on Functional Programming, 2010. Google Scholar
Digital Library
- A. V. Deursen, P. Klint, and F. Tip. Origin tracking. Journal of Symbolic Computation, 15(5--6), 1993. Google Scholar
Digital Library
- R. K. Dybvig, D. P. Friedman, and C. T. Haynes. Expansion-passing style: A general macro mechanism. In Lisp and Symbolic Computation, 1988.Google Scholar
Cross Ref
- 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. Static analysis for syntax objects. In International Conference on Functional Programming, 2006. Google Scholar
Digital Library
- C. Flanagan, A. Sabry, B. F. Duba, and M. Felleisen. The essence of compiling with continuations. In Programming Languages Design and Implementation, 1993. Google Scholar
Digital Library
- J. N. Foster, M. B. Greenwald, J. T. Moore, B. C. Pierce, and A. Schmitt. Combinators for bi-directional tree transformations: a linguistic approach to the view update problem. In Principles of Programming Languages, 2005. Google Scholar
Digital Library
- A. Guha, C. Saftoiu, and S. Krishnamurthi. The essence of JavaScript. In European Conference on Object-oriented Programming, 2010. Google Scholar
Digital Library
- J. Hennessy. Symbolic debugging of optimized code. Transactions on Programming Languages and Systems, 4(3), 1982. Google Scholar
Digital Library
- U. Hölzle, C. Chambers, and D. Ungar. Debugging optimized code with dynamic deoptimization. In Programming Languages Design and Implementation, 1992. Google Scholar
Digital Library
- E. Kohlbecker, D. P. Friedman, M. Felleisen, and B. Duba. Hygienic macro expansion. In ACM Conference on LISP and Functional Programming, 1986. Google Scholar
Digital Library
- E. E. Kohlbecker and M. Wand. Macro-by-example: Deriving syntactic transformations from their specifications. In Principles of Programming Languages, 1987. Google Scholar
Digital Library
- S. Krishnamurthi. Automata via macros. Journal of Functional Programming, 16(3), 2006. Google Scholar
Digital Library
- S. Krishnamurthi, M. Felleisen, and B. F. Duba. From macros to reusable generative programming. In Generative and Component-Based Software Engineering, 1999. Google Scholar
Digital Library
- F. Lorenzen and S. Erdweg. Modular and automated type-soundness for language extensions. In International Conference on Functional Programming, 2013. Google Scholar
Digital Library
- R. Perera, U. A. Acar, J. Cheney, and P. B. Levy. Functional programs that explain their work. In International Conference on Functional Programming, 2012. Google Scholar
Digital Library
- G. Pettyjohn, J. Clements, J. Marshall, S. Krishnamurthi, and M. Felleisen. Continuations from generalized stack inspection. In International Conference on Functional Programming, 2005. Google Scholar
Digital Library
- G. Roşu and T. F. Şerbănuţă. An overview of the K semantic framework. Journal of Logic and Algebraic Programming, 79(6), 2010.Google Scholar
Cross Ref
- P. Stevens. A landscape of bidirectional model transformations. In Generative and Transformational Techniques in Software Engineering II. Springer-Verlag, 2008. Google Scholar
Digital Library
- The Coq Development Team. The Coq Proof Assistant Reference Manual, version 8.4 edition, 2012.Google Scholar
Index Terms
Resugaring: lifting evaluation sequences through syntactic sugar
Recommendations
Inferring type rules for syntactic sugar
PLDI 2018: Proceedings of the 39th ACM SIGPLAN Conference on Programming Language Design and ImplementationType systems and syntactic sugar are both valuable to programmers, but sometimes at odds. While sugar is a valuable mechanism for implementing realistic languages, the expansion process obscures program source structure. As a result, type errors can ...
Resugaring: lifting evaluation sequences through syntactic sugar
PLDI '14: Proceedings of the 35th ACM SIGPLAN Conference on Programming Language Design and ImplementationSyntactic sugar is pervasive in language technology. It is used to shrink the size of a core language; to define domain-specific languages; and even to let programmers extend their language. Unfortunately, syntactic sugar is eliminated by transformation,...
Inferring scope through syntactic sugar
Many languages use syntactic sugar to define parts of their surface language in terms of a smaller core. Thus some properties of the surface language, like its scoping rules, are not immediately evident. Nevertheless, IDEs, refactorers, and other tools ...







Comments