skip to main content
research-article

Reflection in direct style

Published:22 October 2011Publication History
Skip Abstract Section

Abstract

A reflective language enables us to access, inspect, and/or modify the language semantics from within the same language framework. Although the degree of semantics exposure differs from one language to another, the most powerful approach, referred to as the behavioral reflection, exposes the entire language semantics (or the language interpreter) that defines behavior of user programs for user inspection/modification. In this paper, we deal with the behavioral reflection in the context of a functional language Scheme. In particular, we show how to construct a reflective interpreter where user programs are interpreted by the tower of metacircular interpreters and have the ability to change any parts of the interpreters during execution. Its distinctive feature compared to the previous work is that the metalevel interpreters observed by users are written in direct style. Based on the past attempt of the present author, the current work solves the level-shifting anomaly by defunctionalizing and inspecting the top of the continuation frames. The resulting system enables us to freely go up and down the levels and access/modify the direct-style metalevel interpreter. This is in contrast to the previous system where metalevel interpreters were written in continuation-passing style (CPS) and only CPS functions could be exposed to users for modification.

References

  1. Asai, K. "Reflecting on the Metalevel Interpreter Written in Direct Style," Presented at the International Lisp Conference 2003 (ILC 2003), New York City, 12 pages (October 2003).Google ScholarGoogle Scholar
  2. Asai, K., S. Matsuoka, and A. Yonezawa "Duplication and Partial Evaluation - For a Better Understanding ofReflective Languages -," Lisp and Symbolic Computation, Vol. 9, Nos. 2/3, pp. 203--241, Kluwer Academic Publishers (May/June 1996). Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Bolz, C. F., A. Cuni, M. Fijalkowski, and A. Rigo "Tracing the Meta-Level: PyPy's Tracing JIT Compiler," Proceedings of the 4th workshop on the Implementation, Compilation, Optimization of Object-Oriented Languages and Programming Systems, pp. 18--25 (July 2009). Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Danvy, O., and A. Filinski "Abstracting Control," Proceedings of the 1990 ACM Conference on Lisp and Functional Programming, pp. 151--160 (June 1990). Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Danvy, O., and K. Malmkjæ r "Intensions and Extensions in a Reflective Tower," Conference Record of the 1988 ACM Symposium on Lisp and Functional Programming, pp. 327--341 (July 1988). Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Friedman, D. P., and M. Wand "Reification: Reflection without Metaphysics," Conference Record of the 1984 ACM Symposium on Lisp and Functional Programming, pp. 348--355 (August 1984). Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Hutton, G., and E. Meijer "Monadic Parsing in Haskell," Journal of Functional Programming, Vol. 8, No. 4, pp. 437--444, Cambridge University Press (July 1998). Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Jefferson, S., and D. P. Friedman "A Simple Reflective Interpreter," Lisp and Symbolic Computation, Vol. 9, Nos. 2/3, pp. 181--202, Kluwer Academic Publishers (May/June 1996). Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Jones, N. D., C. K. Gomard, and P. Sestoft Partial Evaluation and Automatic Program Generation, New York: Prentice-Hall (1993). Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Kameyama, Y., and M. Hasegawa "A Sound and Complete Axiomatization of Delimited Continuations," Proceedings of the eighth ACM SIGPLAN International Conference on Functional Programming (ICFP'03), pp. 177--188 (August 2003). Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Kiczales, G., J. des Rivières, and D. G. Bobrow The Art of the Metaobject Protocol, Cambridge: MIT Press (1991). Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Kiczales, G., J. Lamping, A. Mendhekar, C. Maeda, C. Videira Lopes, J-M. Loingtier, and J. Irwin "Aspect-Oriented Programming," Proceedings of the European Conference on Object-OrientedProgramming (ECOOP'97), pp. 220--242 (1997).Google ScholarGoogle Scholar
  13. Masuhara, H., and A. Yonezawa "Design and Partial Evaluation of Meta-objects for a ConcurrentReflective Language," Proceedings of the European Conference on Object-Oriented Programming (ECOOP'98), LNCS 1445, pp. 418--439 (July 1998). Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Reynolds, J. C. "Definitional Interpreters for Higher-Order Programming Languages," Proceedings of the ACM National Conference, Vol. 2, pp. 717--740, (August 1972), reprinted in Higher-Order and Symbolic Computation, Vol. 11, No. 4, pp. 363--397, Kluwer Academic Publishers (December 1998). Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Smith, B. C. "Reflection and Semantics in Lisp," Conference Record of the 14th Annual ACM Symposium on Principles of Programming Languages, pp. 23--35 (January 1984). Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Verwaest, T., C. Bruni, D. Gurtner, A. Lienhard, and O. Niestrasz "PINOCCHIO: Bringing Reflection to Life with First-Class Interpreters," Proceedings of the ACM International Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA '10), pp. 774--789, (October 2010). Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Wand, M., and D. P. Friedman "The Mystery of the Tower Revealed: A Non-Reflective Description of the Reflective Tower," Conference Record of the 1986 ACM Symposium on Lisp and Functional Programming, pp. 298--307 (August 1986). Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Reflection in direct style

      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!