Abstract
The multi-stage programming paradigm supports runtime code generation and execution. Though powerful, its potential is impeded by the lack of static analysis support. Van Horn and Might proposed a general-purpose approach to systematically develop static analyses by transforming an environmental abstract machine, which evolves a control string, an environment and a continuation as a program evaluates. To the best of our knowledge, no such semantics exists for a multi-stage language like MetaML.
We develop and prove correct an environmental abstract machine semantics for MetaML by gradually refining the reference substitutional structural operational semantics. Highlights of our approach include leveraging explicit substitutions to bridge the gap between substitutional and environmental semantics, and devising meta-environments to model the complexities of variable bindings in multi-stage environmental semantics.
- Martín Abadi, Luca Cardelli, Pierre-Louis Curien, and Jean-Jacques Lévy. 1990. Explicit substitutions. In Proceedings of the 17th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL '90). ACM, New York, NY, USA, 31-46. Google Scholar
Digital Library
- Mads Sig Ager, Dariusz Biernacki, Olivier Danvy, and Jan Midtgaard. 2003. A functional correspondence between evaluators and abstract machines. In Proceedings of the 5th ACM SIGPLAN International Conference on Principles and Practice of Declaritive Programming (PPDP '03). ACM, NewYork, NY, USA, 8-19. Google Scholar
Digital Library
- Pierre-Louis Curien. 1985. Categorical combinatory logic. In Automata, Languages and Programming: 12th Colloquium, ICALP '85, Wilfried Brauer (Ed.). Lecture Notes in Computer Science, Vol. 194. Springer, Berlin, Heidelberg, 130-139. Google Scholar
Digital Library
- Olivier Danvy and Andrzej Filinski. 1990. Abstracting control. In Proceedings of the 1990 ACM Conference on LISP and Functional Programming (LFP '90). ACM, New York, NY, USA, 151-160. Google Scholar
Digital Library
- David Darais, Nicholas Labich, Phúc C. Nguyen, and David Van Horn. 2017. Abstracting definitional interpreters (functional pearl). Proc. ACM Program. Lang. 1, ICFP, Article 12 (Aug. 2017), 25 pages. Google Scholar
Digital Library
- Matthias Felleisen, Robert Bruce Findler, and Matthew Flatt. 2009. Semantics Engineering with PLT Redex (1st ed.). The MIT Press. Google Scholar
Digital Library
- Rui Ge. 2016. Refining Semantics for Multi-stage Programming. Master's thesis. University of British Columbia.Google Scholar
- Neil D. Jones, Carsten K. Gomard, and Peter Sestoft. 1993. Partial Evaluation and Automatic Program Generation. Prentice-Hall, Inc., Upper Saddle River, NJ, USA. Google Scholar
Digital Library
- Yukiyoshi Kameyama, Oleg Kiselyov, and Chung-chieh Shan. 2008. Closing the stage: from staged code to typed closures. In Proceedings of the 2008 ACM SIGPLAN Symposium on Partial Evaluation and Semantics-based Program Manipulation (PEPM '08). ACM, New York, NY, USA, 147-157. Google Scholar
Digital Library
- Yukiyoshi Kameyama, Oleg Kiselyov, and Chung-chieh Shan. 2009. Shifting the stage: staging with delimited control. In Proceedings of the 2009 ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation (PEPM '09). ACM, New York, NY, USA, 111-120. Google Scholar
Digital Library
- Peter J. Landin. 1964. The mechanical evaluation of expressions. Comput. J. 6, 4 (1964), 308-320.Google Scholar
Cross Ref
- Peter J. Landin. 1966. The next 700 programming languages. Commun. ACM 9, 3 (1966), 157-166. Google Scholar
Digital Library
- Eugenio Moggi, Walid Taha, Zine El-Abidine Benaissa, and Tim Sheard. 1999. An idealized MetaML: simpler, and more expressive. In Programming Languages and Systems: 8th European Symposium on Programming, ESOP '99, S. Doaitse Swierstra (Ed.). Lecture Notes in Computer Science, Vol. 1576. Springer, Berlin, Heidelberg, 193-207. Google Scholar
Digital Library
- Damien Pous and Davide Sangiorgi. 2012. Enhancements of the bisimulation proof method. In Advanced Topics in Bisimulation and Coinduction, Davide Sangiorgi and Jan Rutten (Eds.). Cambridge Tracts in Theoretical Computer Science, Vol. 52. Cambridge University Press, New York, NY, USA, Chapter 6, 233-289.Google Scholar
- Kristoffer Høgsbro Rose. 1996. Explicit Substitution: Tutorial & Survey. Technical Report. BRICS, Department of Computer Science, University of Aarhus.Google Scholar
- Davide Sangiorgi. 2011. Introduction to Bisimulation and Coinduction. Cambridge University Press, New York, NY, USA. Google Scholar
Digital Library
- Tim Sheard. 1999. Using MetaML: A staged programming language. In Advanced Functional Programming: Third International School, AFP'98, S. Doaitse Swierstra, José N. Oliveira, and Pedro R. Henriques (Eds.). Lecture Notes in Computer Science, Vol. 1608. Springer, Berlin, Heidelberg, 207-239.Google Scholar
- Tim Sheard. 2001. Accomplishments and research challenges in meta-programming. In Semantics, Applications, and Implementation of Program Generation: Second International Workshop, SAIG 2001 Proceedings, Walid Taha (Ed.). Lecture Notes in Computer Science, Vol. 2196. Springer, Berlin, Heidelberg, 2-44. Google Scholar
Digital Library
- Walid Taha. 1999. A sound reduction semantics for untyped CBN multi-stage computation. Or, the theory of MetaML is non-trival. In Proceedings of the 2000 ACM SIGPLAN Workshop on Partial Evaluation and Semantics-based Program Manipulation (PEPM '00). ACM, New York, NY, USA, 34-43. Google Scholar
Digital Library
- Walid Taha. 2004. A gentle introduction to multi-stage programming. In Domain-Specific Program Generation: International Seminar, Christian Lengauer, Don Batory, Charles Consel, and Martin Odersky (Eds.). Lecture Notes in Computer Science, Vol. 3016. Springer, Berlin, Heidelberg, 30-50.Google Scholar
Cross Ref
- Walid Taha, Zine-El-Abidine Benaissa, and Tim Sheard. 1998. Multistage programming: axiomatization and type safety. In Automata, Languages and Programming: 25th International Colloquium, ICALP'98 Proceedings, Kim G. Larsen, Sven Skyum, and Glynn Winskel (Eds.). Lecture Notes in Computer Science, Vol. 1443. Springer Berlin Heidelberg, Berlin, Heidelberg, 918-929. Google Scholar
Digital Library
- Walid Taha and Michael Florentin Nielsen. 2003. Environment classifiers. In Proceedings of the 30th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL '03). ACM, New York, NY, USA, 26-37. Google Scholar
Digital Library
- Walid Taha and Tim Sheard. 1997. Multi-stage programming with explicit annotations. In Proceedings of the 1997 ACM SIGPLAN Symposium on Partial Evaluation and Semantics-based Program Manipulation (PEPM '97). ACM, New York, NY, USA, 203-217. Google Scholar
Digital Library
- Walid Taha and Tim Sheard. 2000. MetaML and multi-stage programming with explicit annotations. Theoretical Computer Science 248, 1 (2000), 211-242. PEPM'97. Google Scholar
Digital Library
- Walid Mohamed Taha. 1999. Multistage Programming: Its Theory and Applications. Ph.D. Dissertation. Oregon Graduate Institute of Science and Technology. https://www.cs.rice.edu/~taha/publications/thesis/thesis.pdfGoogle Scholar
- David Van Horn and Matthew Might. 2012. Systematic abstraction of abstract machines. Journal of Functional Programming 22, 4-5 (2012), 705-746. Google Scholar
Digital Library
Index Terms
Refining semantics for multi-stage programming
Recommendations
Refining semantics for multi-stage programming
GPCE 2017: Proceedings of the 16th ACM SIGPLAN International Conference on Generative Programming: Concepts and ExperiencesThe multi-stage programming paradigm supports runtime code generation and execution. Though powerful, its potential is impeded by the lack of static analysis support. Van Horn and Might proposed a general-purpose approach to systematically develop ...
Staged abstract interpreters: fast and modular whole-program analysis via meta-programming
It is well known that a staged interpreter is a compiler: specializing an interpreter to a given program produces an equivalent executable that runs faster. This connection is known as the first Futamura projection. It is even more widely known that an ...
A practical unification of multi-stage programming and macros
GPCE 2018: Proceedings of the 17th ACM SIGPLAN International Conference on Generative Programming: Concepts and ExperiencesProgram generation is indispensable. We propose a novel unification of two existing metaprogramming techniques: multi-stage programming and hygienic generative macros. The former supports runtime code generation and execution in a type-safe manner while ...







Comments