skip to main content
research-article
Open Access

Call-by-need is clairvoyant call-by-value

Published:26 July 2019Publication History
Skip Abstract Section

Abstract

Call-by-need evaluation, also known as lazy evaluation, provides two key benefits: compositional programming and infinite data. The standard semantics for laziness is Launchbury’s natural semantics DBLP:conf/popl/Launchbury93, which uses a heap to memoise the results of delayed evaluations. However, the stateful nature of this heap greatly complicates reasoning about the operational behaviour of lazy programs. In this article, we propose an alternative semantics for laziness, clairvoyant evaluation, that replaces the state effect with nondeterminism, and prove this semantics equivalent in a strong sense to the standard semantics. We show how this new semantics greatly simplifies operational reasoning, admitting much simpler proofs of a number of results from the literature, and how it leads to the first denotational cost semantics for lazy evaluation.

Skip Supplemental Material Section

Supplemental Material

a114-hackett.webm

References

  1. Zena M Ariola and Matthias Felleisen. 1997. The Call-By-Need Lambda Calculus. Journal of Functional Programming 7, 3 (1997). Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Zena M. Ariola, Matthias Felleisen, John Maraist, Martin Odersky, and Philip Wadler. 1995. A Call-by-Need Lambda Calculus. In Principles of Programming Languages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Richard S. Bird. 1984. Using Circular Programs to Eliminate Multiple Traversals of Data. Acta Informatica 21, 3 (1984). Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Bror Bjerner and Sören Holmström. 1989. A Composition Approach to Time Analysis of First Order Lazy Functional Programs. In International Conference on Functional Programming Languages and Computer Architecture. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Bernd Braßel, Michael Hanus, Sebastian Fischer, Frank Huch, and Germán Vidal. 2007. Lazy Call-By-Value Evaluation. In ACM SIGPLAN Notices, Vol. 42. ACM, 265–276. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Norman Danner, Daniel R. Licata, and Ramyaa Ramyaa. 2015. Denotational Cost Semantics for Functional Languages with Inductive Types. In International Conference on Functional Programming. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Dan R. Ghica. 2005. Slot Games: A Quantitative Model of Computation. In Principles of Programming Languages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Jörgen Gustavsson and David Sands. 1999. A Foundation for Space-Safe Transformations of Call-by-Need Programs. Electronic Notes on Theoretical Computer Science 26 (1999).Google ScholarGoogle Scholar
  9. Jörgen Gustavsson and David Sands. 2001. Possibilities and Limitations of Call-by-Need Space Improvement. In International Conference on Functional Programming. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Jennifer Hackett and Graham Hutton. 2014. Worker/Wrapper/Makes It/Faster. In International Conference on Functional Programming. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Jennifer Hackett and Graham Hutton. 2018. Parametric Polymorphism and Operational Improvement. Proceedings of the ACM on Programming Languages 2, ICFP, Article 68 (2018). Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Peter Henderson and James H Morris. 1976. A Lazy Evaluator. In Principles on Programming Languages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Catherine Hope. 2008. A Functional Semantics for Space and Time. Ph.D. Dissertation. University of Nottingham.Google ScholarGoogle Scholar
  14. John Hughes. 1989. Why Functional Programming Matters. Comput. J. 32, 2 (1989). Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. J. M. E. Hyland and C.-H.L. Ong. 2000. On Full Abstraction for PCF: I, II, and III. Information and Computation 163, 2 (2000). Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Mark B. Josephs. 1989. The Semantics of Lazy Functional Languages. Theoretical Computer Science 68, 1 (1989). Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Steffen Jost, Kevin Hammond, Hans-Wolfgang Loidl, and Martin Hofmann. 2010. Static Determination of Quantitative Resource Usage for Higher-Order Programs. In ACM SIGPLAN Notices, Vol. 45. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. John Launchbury. 1993. A Natural Semantics for Lazy Evaluation. In Principles of Programming Languages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. John Maraist, Martin Odersky, David N. Turner, and Philip Wadler. 1999. Call-By-Name, Call-By-Value, Call-By-Need and the Linear Lambda Calculus. Theoretical Computer Science 228, 1-2 (1999). Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. John Maraist, Martin Odersky, and Philip Wadler. 1998. The Call-by-Need Lambda Calculus. Journal of Functional Programming 8, 3 (1998). Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Andrew Moran and David Sands. 1999a. Improvement in a Lazy Context: An Operational Theory for Call-by-Need. (1999). Extended version of { Moran and Sands 1999b }, available at http://tinyurl.com/ohuv8ox .Google ScholarGoogle Scholar
  22. Andrew Moran and David Sands. 1999b. Improvement in a Lazy Context: An Operational Theory for Call-by-Need. In Principles of Programming Languages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. James Hiram Morris. 1969. Lambda-Calculus Models of Programming Languages. Ph.D. Dissertation. MIT.Google ScholarGoogle Scholar
  24. Keiko Nakata. 2010. Denotational Semantics for Lazy Initialization of letrec. In Fixed Points in Computer Science.Google ScholarGoogle Scholar
  25. Chris Okasaki. 1999. Purely Functional Data Structures. Cambridge University Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Andrew M Pitts. 2000. Operational Semantics and Program Equivalence. In International Summer School on Applied Semantics. Springer, 378–412. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Mads Rosendahl. 1989. Automatic Complexity Analysis. In Functional Programming Languages and Computer Architecture. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. David Sands. 1991. Operational Theories of Improvement in Functional Languages. In Glasgow Workshop on Functional Programming. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. David Sands. 1997. Improvement Theory and its Applications. In Higher Order Operational Techniques in Semantics, Publications of the Newton Institute. Cambridge University Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Patrick M. Sansom and Simon L. Peyton Jones. 1997. Formally Based Profiling for Higher-Order Functional Languages. ACM Transactions on Programming Languages and Systems 19, 2 (1997). Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Manfred Schmidt-Schauß and Nils Dallmeyer. 2018. Space Improvements and Equivalences in a Functional Core Language. arXiv preprint arXiv:1802.06498 (2018).Google ScholarGoogle Scholar
  32. Manfred Schmidt-Schauß and David Sabel. 2015a. Improvements in a Functional Core Language with Call-By-Need Operational Semantics. In Principles and Practice of Declarative Programming. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Manfred Schmidt-Schauß and David Sabel. 2015b. Sharing-Aware Improvements in a Call-by-Need Functional Core Language. In Implementation and Application of Functional Programming Languages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Daniel Seidel and Janis Voigtländer. 2011. Improvements for Free. In Quantitative Aspects of Programming Languages.Google ScholarGoogle Scholar
  35. Hugo Simões, Pedro Vasconcelos, Mário Florido, Steffen Jost, and Kevin Hammond. 2012. Automatic Amortised Analysis of Dynamic Memory Allocation for Lazy Functional Programs. In International Conference on Functional Programming. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. David A Turner. 1982. Recursion Equations as a Programming Language. In Functional Programming and its Applications: An Advanced Course. Cambridge University Press.Google ScholarGoogle Scholar
  37. Philip Wadler and John Hughes. 1987. Projections for Strictness Analysis. In Functional Programming Languages and Computer Architecture. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Call-by-need is clairvoyant call-by-value

        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

        • Published in

          cover image Proceedings of the ACM on Programming Languages
          Proceedings of the ACM on Programming Languages  Volume 3, Issue ICFP
          August 2019
          1054 pages
          EISSN:2475-1421
          DOI:10.1145/3352468
          Issue’s Table of Contents

          Copyright © 2019 Owner/Author

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 26 July 2019
          Published in pacmpl Volume 3, Issue ICFP

          Permissions

          Request permissions about this article.

          Request Permissions

          Check for updates

          Author Tags

          Qualifiers

          • research-article

        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!