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 ScholarDigital 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 ScholarDigital 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 ScholarDigital 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 ScholarDigital Library
- R. Culpepper and M. Felleisen. Fortifying macros. In International Conference on Functional Programming, 2010. Google ScholarDigital Library
- A. V. Deursen, P. Klint, and F. Tip. Origin tracking. Journal of Symbolic Computation, 15(5--6), 1993. Google ScholarDigital 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 ScholarCross Ref
- M. Felleisen, R. B. Findler, and M. Flatt. Semantics Engineering with PLT Redex. MIT Press, 2009. Google ScholarDigital Library
- D. Fisher and O. Shivers. Static analysis for syntax objects. In International Conference on Functional Programming, 2006. Google ScholarDigital 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 ScholarDigital 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 ScholarDigital Library
- A. Guha, C. Saftoiu, and S. Krishnamurthi. The essence of JavaScript. In European Conference on Object-oriented Programming, 2010. Google ScholarDigital Library
- J. Hennessy. Symbolic debugging of optimized code. Transactions on Programming Languages and Systems, 4(3), 1982. Google ScholarDigital Library
- U. Hölzle, C. Chambers, and D. Ungar. Debugging optimized code with dynamic deoptimization. In Programming Languages Design and Implementation, 1992. Google ScholarDigital Library
- E. Kohlbecker, D. P. Friedman, M. Felleisen, and B. Duba. Hygienic macro expansion. In ACM Conference on LISP and Functional Programming, 1986. Google ScholarDigital Library
- E. E. Kohlbecker and M. Wand. Macro-by-example: Deriving syntactic transformations from their specifications. In Principles of Programming Languages, 1987. Google ScholarDigital Library
- S. Krishnamurthi. Automata via macros. Journal of Functional Programming, 16(3), 2006. Google ScholarDigital Library
- S. Krishnamurthi, M. Felleisen, and B. F. Duba. From macros to reusable generative programming. In Generative and Component-Based Software Engineering, 1999. Google ScholarDigital Library
- F. Lorenzen and S. Erdweg. Modular and automated type-soundness for language extensions. In International Conference on Functional Programming, 2013. Google ScholarDigital 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 ScholarDigital 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 ScholarDigital 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 ScholarCross Ref
- P. Stevens. A landscape of bidirectional model transformations. In Generative and Transformational Techniques in Software Engineering II. Springer-Verlag, 2008. Google ScholarDigital 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 '18Type 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 ...
Hygienic resugaring of compositional desugaring
ICFP 2015: Proceedings of the 20th ACM SIGPLAN International Conference on Functional ProgrammingSyntactic sugar is widely used in language implementation. Its benefits are, however, offset by the comprehension problems it presents to programmers once their program has been transformed. In particular, after a transformed program has begun to ...
Resugaring: lifting evaluation sequences through syntactic sugar
PLDI '14Syntactic 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,...
Comments