Defunctionalized Interpreters for Call-by-Need Evaluation

  • Olivier Danvy
  • Kevin Millikin
  • Johan Munk
  • Ian Zerny
Part of the Lecture Notes in Computer Science book series (LNCS, volume 6009)


Starting from the standard call-by-need reduction for the λ-calculus that is common to Ariola, Felleisen, Maraist, Odersky, and Wadler, we inter-derive a series of hygienic semantic artifacts: a reduction-free stateless abstract machine, a continuation-passing evaluation function, and what appears to be the first heapless natural semantics for call-by-need evaluation. Furthermore we observe that a data structure and a judgment in this natural semantics are in defunctionalized form. The refunctionalized counterpart of this evaluation function is an extended direct semantics in the sense of Cartwright and Felleisen.

Overall, the semantic artifacts presented here are simpler than many other such artifacts that have been independently worked out, and which require ingenuity, skill, and independent soundness proofs on a case-by-case basis. They are also simpler to inter-derive because the inter-derivational tools (e.g., refocusing and defunctionalization) already exist.


Operational Semantic Functional Programming Abstract Machine Lambda Calculus Evaluation Context 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Ager, M.S., Danvy, O., Midtgaard, J.: A functional correspondence between call-by-need evaluators and lazy abstract machines. Information Processing Letters 90(5), 223–232 (2004)zbMATHCrossRefMathSciNetGoogle Scholar
  2. 2.
    Ariola, Z.M., Felleisen, M.: The call-by-need lambda calculus. Journal of Functional Programming 7(3), 265–301 (1997)zbMATHCrossRefMathSciNetGoogle Scholar
  3. 3.
    Barendregt, H.: The Lambda Calculus: Its Syntax and Semantics. In: Studies in Logic and the Foundation of Mathematics, revised edn., vol. 103, North-Holland, Amsterdam (1984)Google Scholar
  4. 4.
    Biernacka, M., Danvy, O.: A syntactic correspondence between context-sensitive calculi and abstract machines. Theoretical Computer Science 375(1-3), 76–108 (2007)zbMATHCrossRefMathSciNetGoogle Scholar
  5. 5.
    Bloo, R., Rose, K.H.: Preservation of strong normalisation in named lambda calculi with explicit substitution and garbage collection. In: CSN 1995: Computer Science in the Netherlands, pp. 62–72 (1995)Google Scholar
  6. 6.
    Cartwright, R., Felleisen, M.: Extensible denotational language specifications. In: Hagiya, M., Mitchell, J.C. (eds.) TACS 1994. LNCS, vol. 789, pp. 244–272. Springer, Heidelberg (1994)Google Scholar
  7. 7.
    Danvy, O.: Back to direct style. Science of Computer Programming 22(3), 183–195 (1994)zbMATHCrossRefMathSciNetGoogle Scholar
  8. 8.
    Danvy, O.: Defunctionalized interpreters for programming languages. In: Thiemann, P. (ed.) Proceedings of the 2008 ACM SIGPLAN International Conference on Functional Programming (ICFP 2008), SIGPLAN Notices, Victoria, British Columbia, vol. 43(9), pp. 131–142. ACM Press, New York (2008) (invited talk)Google Scholar
  9. 9.
    Danvy, O.: From reduction-based to reduction-free normalization. In: Koopman, P., Plasmeijer, R., Swierstra, D. (eds.) AFP 2008. LNCS, vol. 5832, pp. 66–164. Springer, Heidelberg (2009)CrossRefGoogle Scholar
  10. 10.
    Danvy, O., Lawall, J.L.: Back to direct style II: First-class continuations. In: Clinger, W. (ed.) Proceedings of the 1992 ACM Conference on Lisp and Functional Programming, LISP Pointers, San Francisco, California, vol. V(1), pp. 299–310. ACM Press, New York (1992)CrossRefGoogle Scholar
  11. 11.
    Danvy, O., Millikin, K.: On the equivalence between small-step and big-step abstract machines: a simple application of lightweight fusion. Information Processing Letters 106(3), 100–109 (2008)CrossRefMathSciNetGoogle Scholar
  12. 12.
    Danvy, O., Millikin, K.: Refunctionalization at work. Science of Computer Programming 74(8), 534–549 (2009)zbMATHCrossRefGoogle Scholar
  13. 13.
    Danvy, O., Nielsen, L.R.: Defunctionalization at work. In: Søndergaard, H. (ed.) Proceedings of the Third International ACM SIGPLAN Conference on Principles and Practice of Declarative Programming (PPDP 2001), Firenze, Italy, pp. 162–174. ACM Press, New York (2001)CrossRefGoogle Scholar
  14. 14.
    Danvy, O., Nielsen, L.R.: Refocusing in reduction semantics. Research Report BRICS RS-04-26, Department of Computer Science, Aarhus University, Aarhus, Denmark (November 2004); A preliminary version appeared in the informal proceedings of the Second International Workshop on Rule-Based Programming (RULE 2001). Electronic Notes in Theoretical Computer Science, vol. 59.4 (2001)Google Scholar
  15. 15.
    Felleisen, M., Hieb, R.: The revised report on the syntactic theories of sequential control and state. Theoretical Computer Science 103(2), 235–271 (1992)zbMATHCrossRefMathSciNetGoogle Scholar
  16. 16.
    Friedman, D.P., Ghuloum, A., Siek, J.G., Winebarger, L.: Improving the lazy Krivine machine. Higher-Order and Symbolic Computation 20(3), 271–293 (2007)zbMATHCrossRefGoogle Scholar
  17. 17.
    Fünfrocken, S.: Transparent migration of Java-based mobile agents. In: Rothermel, K., Hohl, F. (eds.) MA 1998. LNCS, vol. 1477, pp. 26–37. Springer, Heidelberg (1998)CrossRefGoogle Scholar
  18. 18.
    Garcia, R., Lumsdaine, A., Sabry, A.: Lazy evaluation and delimited control. In: Pierce, B.C. (ed.) Proceedings of the Thirty-Sixth Annual ACM Symposium on Principles of Programming Languages, SIGPLAN Notices, Savannah, GA, vol. 44(1), pp. 153–164. ACM Press, New York (2009)Google Scholar
  19. 19.
    Henderson, P., Morris Jr., J.H.: A lazy evaluator. In: Graham, S.L. (ed.) Proceedings of the Third Annual ACM Symposium on Principles of Programming Languages, pp. 95–103. ACM Press, New York (1976)Google Scholar
  20. 20.
    Huet, G.: The zipper. Journal of Functional Programming 7(5), 549–554 (1997)zbMATHCrossRefMathSciNetGoogle Scholar
  21. 21.
    Josephs, M.B.: The semantics of lazy functional languages. Theoretical Computer Science 68, 105–111 (1989)zbMATHCrossRefMathSciNetGoogle Scholar
  22. 22.
    Landin, P.J.: The mechanical evaluation of expressions. The Computer Journal 6(4), 308–320 (1964)zbMATHGoogle Scholar
  23. 23.
    Launchbury, J.: A natural semantics for lazy evaluation. In: Graham, S.L. (ed.) Proceedings of the Twentieth Annual ACM Symposium on Principles of Programming Languages, Charleston, South Carolina, pp. 144–154. ACM Press, New York (1993)Google Scholar
  24. 24.
    Loitsch, F.: Scheme to JavaScript Compilation. PhD thesis, Université de Nice, Nice, France (March 2009)Google Scholar
  25. 25.
    Maraist, J., Odersky, M., Wadler, P.: The call-by-need lambda calculus. Journal of Functional Programming 8(3), 275–317 (1998)zbMATHCrossRefMathSciNetGoogle Scholar
  26. 26.
    Munk, J.: A study of syntactic and semantic artifacts and its application to lambda definability, strong normalization, and weak normalization in the presence of state. Master’s thesis, Department of Computer Science, Aarhus University, Aarhus, Denmark. BRICS research report RS-08-3 (May 2007)Google Scholar
  27. 27.
    Ohori, A., Sasano, I.: Lightweight fusion by fixed point promotion. In: Felleisen, M. (ed.) Proceedings of the Thirty-Fourth Annual ACM Symposium on Principles of Programming Languages, SIGPLAN Notices, Nice, France, vol. 42(1), pp. 143–154. ACM Press, New York (2007)CrossRefGoogle Scholar
  28. 28.
    Pettyjohn, G., Clements, J., Marshall, J., Krishnamurthi, S., Felleisen, M.: Continuations from generalized stack inspection. In: Pierce, B. (ed.) Proceedings of the 2005 ACM SIGPLAN International Conference on Functional Programming (ICFP 2005), SIGPLAN Notices, Tallinn, Estonia, vol. 40(9), pp. 216–227. ACM Press, New York (2005)CrossRefGoogle Scholar
  29. 29.
    Reynolds, J.C.: Definitional interpreters for higher-order programming languages. In: Proceedings of 25th ACM National Conference, Boston, Massachusetts, pp. 717–740 (1972); Reprinted in Higher-Order and Symbolic Computation 11(4), 363–397 (1998), with a foreword [30]Google Scholar
  30. 30.
    Reynolds, J.C.: Definitional interpreters revisited. Higher-Order and Symbolic Computation 11(4), 355–361 (1998)zbMATHCrossRefGoogle Scholar
  31. 31.
    Sekiguchi, T., Masuhara, H., Yonezawa, A.: A simple extension of Java language for controllable transparent migration and its portable implementation. In: Ciancarini, P., Wolf, A.L. (eds.) COORDINATION 1999. LNCS, vol. 1594, pp. 211–226. Springer, Heidelberg (1999)Google Scholar
  32. 32.
    Sestoft, P.: Deriving a lazy abstract machine. Journal of Functional Programming 7(3), 231–264 (1997)zbMATHCrossRefMathSciNetGoogle Scholar
  33. 33.
    Tao, W.: A portable mechanism for thread persistence and migration. PhD thesis, University of Utah, Salt Lake City, Utah (2001)Google Scholar
  34. 34.
    Zerny, I.: On graph rewriting, reduction and evaluation. In: Horváth, Z., Zsók, V., Achten, P., Koopman, P. (eds.) Trends in Functional Programming, Komárno, Slovakia, June 2009, vol. 10. Intellect Books (2009) (to appear)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2010

Authors and Affiliations

  • Olivier Danvy
    • 1
  • Kevin Millikin
    • 2
  • Johan Munk
    • 3
  • Ian Zerny
    • 1
  1. 1.Department of Computer ScienceAarhus UniversityAarhus NDenmark
  2. 2.GoogleAarhus NDenmark
  3. 3.Arctic Lake SystemsAarhus NDenmark

Personalised recommendations