skip to main content
article

Staging with control: type-safe multi-stage programming with control operators

Published:23 October 2017Publication History
Skip Abstract Section

Abstract

Staging allows a programmer to write domain-specific, custom code generators. Ideally, a programming language for staging provides all necessary features for staging, and at the same time, gives static guarantee for the safety properties of generated code including well typedness and well scopedness. We address this classic problem for the language with control operators, which allow code optimizations in a modular and compact way. Specifically, we design a staged programming language with the expressive control operators shift0 and reset0, which let us express, for instance, multi-layer let-insertion, while keeping the static guarantee of well typedness and well scopedness. For this purpose, we extend our earlier work on refined environment classifiers which were introduced for the staging language with state. We show that our language is expressive enough to express interesting code generation techniques, and that the type system enjoys type soundness. We also mention a type inference algorithm for our language under reasonable restriction.

References

  1. Cristiano Calcagno, Eugenio Moggi, and Walid Taha. 2004. ML-Like Inference for Classifiers. In Programming Languages and Systems, 13th European Symposium on Programming, ESOP 2004, Held as Part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2004, Barcelona, Spain, March 29 - April 2, 2004, Proceedings. 79–93. Google ScholarGoogle ScholarCross RefCross Ref
  2. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  3. Rowan Davies. 1996. A Temporal-Logic Approach to Binding-Time Analysis. In Proceedings, 11th Annual IEEE Symposium on Logic in Computer Science, New Brunswick, New Jersey, USA, July 27-30, 1996. 184–195. Google ScholarGoogle ScholarCross RefCross Ref
  4. Rowan Davies and Frank Pfenning. 1996. A Modal Analysis of Staged Computation. In Conference Record of The 23rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. ACM, New York, NY, USA, 258–270. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Matthias Felleisen. 1991. On the Expressive Power of Programming Languages. Sci. Comput. Program. 17, 1-3 (1991), 35–75. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Yukiyoshi Kameyama, Oleg Kiselyov, and Chung-chieh Shan. 2015. Combinators for impure yet hygienic code generation. Sci. Comput. Program. 112 (2015), 120–144. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Yukiyoshi Kameyama, Oleg Kiselyov, and Chung-chieh Shan. 2015. Combinators for impure yet hygienic code generation. Sci. Comput. Program. 112 (2015), 120–144. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  9. Oleg Kiselyov. 2014. The design and implementation of BER MetaO-Caml. In International Symposium on Functional and Logic Programming. Springer, 86–102. Google ScholarGoogle ScholarCross RefCross Ref
  10. Oleg Kiselyov. 2014. The Design and Implementation of BER MetaO-Caml - System Description. In Functional and Logic Programming - 12th International Symposium, FLOPS 2014, Kanazawa, Japan, June 4-6, 2014. Proceedings. 86–102. Google ScholarGoogle ScholarCross RefCross Ref
  11. Oleg Kiselyov. 2017. Let-insertion as a primitive. (2017). http://okmij. org/ftp/ML/MetaOCaml.html#genletGoogle ScholarGoogle Scholar
  12. Oleg Kiselyov, Yukiyoshi Kameyama, and Yuto Sudo. 2016. Refined Environment Classifiers - Type- and Scope-Safe Code Generation with Mutable Cells. In Programming Languages and Systems - 14th Asian Symposium, APLAS 2016, Hanoi, Vietnam, November 21-23, 2016, Proceedings. 271–291. Google ScholarGoogle ScholarCross RefCross Ref
  13. Marek Materzok and Dariusz Biernacki. 2011. Subtyping Delimited Continuations. ICFP 2011 46, 9 (Sept. 2011), 81–93. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Marek Materzok and Dariusz Biernacki. 2012. A Dynamic Interpretation of the CPS Hierarchy. In APLAS 2012, Ranjit Jhala and Atsushi Igarashi (Eds.). Lecture Notes in Computer Science, Vol. 7705. Springer Berlin Heidelberg, 296–311. Google ScholarGoogle ScholarCross RefCross Ref
  15. Pierre Neron, Andrew P. Tolmach, Eelco Visser, and Guido Wachsmuth. 2015. A Theory of Name Resolution. In Programming Languages and Systems - 24th European Symposium on Programming, ESOP 2015, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2015, London, UK, April 11-18, 2015. Proceedings. 205– 231. Google ScholarGoogle ScholarCross RefCross Ref
  16. Tiark Rompf. 2016. Lightweight modular staging (LMS): generate all the things! (keynote). In Proceedings of the 2016 ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences, GPCE 2016, Amsterdam, The Netherlands, October 31 -November 1, 2016. 1. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  18. Walid Taha and Tim Sheard. 2000. MetaML and multi-stage programming with explicit annotations. Theor. Comput. Sci. 248, 1-2 (2000), 211–242. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Staging with control: type-safe multi-stage programming with control operators

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!