skip to main content
research-article

Lazy evaluation and delimited control

Published:21 January 2009Publication History
Skip Abstract Section

Abstract

The call-by-need lambda calculus provides an equational framework for reasoning syntactically about lazy evaluation. This paper examines its operational characteristics.

By a series of reasoning steps, we systematically unpack the standard-order reduction relation of the calculus and discover a novel abstract machine definition which, like the calculus, goes "under lambdas." We prove that machine evaluation is equivalent to standard-order evaluation.

Unlike traditional abstract machines, delimited control plays a significant role in the machine's behavior. In particular, the machine replaces the manipulation of a heap using store-based effects with disciplined management of the evaluation stack using control-based effects. In short, state is replaced with control.

To further articulate this observation, we present a simulation of call-by-need in a call-by-value language using delimited control operations.

References

  1. Martín Abadi, Luca Cardelli, Pierre-Louis Curien, and Jean-Jacques Lévy. Explicit substitutions. Journal of Functional Programming, 1 (4): 375--416, 1991.Google ScholarGoogle ScholarCross RefCross Ref
  2. Zena M. Ariola and Matthias Felleisen. The call-by-need lambda calculus. Journal of Functional Programming, 7 (3): 265--301, May 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Zena M. Ariola, John Maraist, Martin Odersky, Matthias Felleisen, and Philip Wadler. A call-by-need lambda calculus. In POPL '95: Proceedings of the 22nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 233--246, New York, NY, USA, 1995. ACM Press. ISBN 0-89791-692-1. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Henk P. Barendregt. The Lambda Calculus, its Syntax and Semantics. North-Holland, Amsterdam, NL, 1981. Studies in Logic and the Foundations of Mathematics.Google ScholarGoogle Scholar
  5. Malgorzata Biernacka and Olivier Danvy. A concrete framework for environment machines. ACM Transactions on Computational Logic, 9 (1): 6, 2007. ISSN 1529--3785. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Haskell Brookes Curry and Robert Feys. Combinatory Logic, Volume I. Studies in Logic and the Foundations of Mathematics. North-Holland, Amsterdam, 1958. Second printing 1968.Google ScholarGoogle Scholar
  7. Olivier Danvy and Andrzej Filinski. Abstracting control. In LFP '90: Proceedings of the 1990 ACM Conference on LISP and Functional Programming, pages 151--160, New York, NY, USA, 1990. ACM. ISBN 0-89791-368-X. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Olivier Danvy and Lasse R. Nielsen. Refocusing in reduction semantics. Technical Report RS-04-26, BRICS, DAIMI, Department of Computer Science, University of Aarhus, Aarhus, Denmark, November 2004.Google ScholarGoogle ScholarCross RefCross Ref
  9. R. Kent Dybvig, Simon Peyton Jones, and Amr Sabry. A monadic framework for delimited continuations. Journal of Functional Programming, 17 (6): 687--730, 2007. ISSN 0956-7968. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Matthias Felleisen. The theory and practice of first-class prompts. In POPL '88: Proceedings of the 15th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 180--190, New York, NY, USA, 1988. ACM. ISBN 0-89791-252-7. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Matthias Felleisen and Matthew Flatt. Programming languages and lambda calculi. Available from http://www.cs.utah.edu/plt/publications/pllc.pdf, January 2002.Google ScholarGoogle Scholar
  12. Matthias Felleisen and Daniel P. Friedman. Control operators, the SECD-machine, and the λ-calculus. In M. Wirsing, editor, Formal Description of Programming Concepts, pages 193--217. North-Holland, 1986.Google ScholarGoogle Scholar
  13. Matthias Felleisen and Robert Hieb. A revised report on the syntactic theories of sequential control and state. Theoretical Computer Science, 103 (2): 235--271, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Daniel P. Friedman and David S. Wise. CONS should not evaluate its arguments. In S. Michaelson and Robin Milner, editors, Automata, Languages and Programming, pages 257--284, Edinburgh, Scotland, 1976. Edinburgh University Press.Google ScholarGoogle Scholar
  15. Daniel P. Friedman, Abdulaziz Ghuloum, Jeremy G. Siek, and Onnie Lynn Winebarger. Improving the lazy Krivine machine. Higher-Order and Symbolic Computation, 20 (3): 271--293, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Jeremy Gibbons and Keith Wansbrough. Tracing lazy functional languages. In Michael E. Houle and Peter Eades, editors, Proceedings of Conference on Computing: The Australian Theory Symposium, pages 11--20, Townsville, January 29-30 1996. Australian Computer Science Communications. ISBN ISSN 0157-3055.Google ScholarGoogle Scholar
  17. Peter Henderson and James H. Morris, Jr. A lazy evaluator. In POPL '76: Proceedings of the 3rd ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages, pages 95--103, New York, NY, USA, 1976. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Yukiyoshi Kameyama, Oleg Kiselyov, and Chung-chieh Shan. Closing the stage: From staged code to typed closures. In PEPM '08: Proceedings of the 2008 ACM SIGPLAN Symposium on Partial Evaluation and Semantics-based Program Manipulation, pages 147--157, New York, NY, USA, 2008. ACM. ISBN 978-1-59593-977-7. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Oleg Kiselyov, Chung-chieh Shan, Daniel P. Friedman, and Amr Sabry. Backtracking, interleaving, and terminating monad transformers: (functional pearl). In ICFP '05: Proceedings of the Tenth ACM SIGPLAN International Conference on Functional Programming, pages 192--203, New York, NY, USA, 2005. ACM. ISBN 1-59593-064-7. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Oleg Kiselyov, Chung-chieh Shan, and Amr Sabry. Delimited dynamic binding. In ICFP '06: Proceedings of the eleventh ACM SIGPLAN international conference on Functional programming, pages 26--37, New York, NY, USA, 2006. ACM. ISBN 1-59593-309-3. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Jean-Louis Krivine. A call-by-name lambda-calculus machine. Higher-Order and Symbolic Computation, 20 (3): 199--207, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. John Launchbury. A natural semantics for lazy evaluation. In POPL '93: Proceedings of the 20th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 144--154, New York, NY, USA, 1993. ACM. ISBN 0-89791-560-7. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. John Maraist, Martin Odersky, and Philip Wadler. The call-by-need lambda calculus. Journal of Functional Programming, 8 (3): 275--317, May 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Eugenio Moggi and Amr Sabry. An abstract monadic semantics for value recursion. Theoretical Informatics and Applications, 38 (4): 375--400, 2004.Google ScholarGoogle ScholarCross RefCross Ref
  25. Chris Okasaki, Peter Lee, and David Tarditi. Call-by-need and continuation-passing style. Lisp and Symbolic Computation, 7 (1): 57--81, January 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Simon L. Peyton Jones and Jon Salkild. The spineless tagless G-machine. In FPCA '89: Proceedings of the Fourth International Conference on Functional Programming Languages and Computer Architecture, pages 184--201, New York, NY, USA, 1989. ACM. ISBN 0-89791-328-0. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Gordon D. Plotkin. Call-by-name, call-by-value and the λ-calculus. Theoretical Computer Science, 1 (2): 125--159, December 1975.Google ScholarGoogle ScholarCross RefCross Ref
  28. Peter Sestoft. Deriving a lazy abstract machine. Journal of Functional Programming, 7 (3): 231--264, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Chung-chieh Shan. A static simulation of dynamic delimited control. Higher-Order and Symbolic Computation, 20 (4): 371--401, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Jay Sussman and Guy L. Steele Jr. Scheme: An interpreter for extended lambda calculus. Higher Order Symbolic Computation, 11 (4): 405--439, 1998. ISSN 1388-3690. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Mitchell Wand and Dale Vaillancourt. Relating models of backtracking. In ICFP '04: Proceedings of the Ninth ACM SIGPLAN International Conference on Functional Programming, pages 54--65, New York, NY, USA, 2004. ACM. ISBN 1-58113-905-5. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Ching-lin Wang. Obtaining lazy evaluation with continuations in Scheme. Information Processing Letters, 35 (2): 93--97, 1990. ISSN 0020-0190. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Hongwei Xi. Evaluation under lambda abstraction. In PLILP '97: Proceedings of the Ninth International Symposium on Programming Languages: Implementations, Logics, and Programs, pages 259--273, London, UK, 1997. Springer-Verlag. ISBN 3-540-63398-7. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Lazy evaluation and delimited control

      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!