Skip to main content
Log in

Code optimizations for lazy evaluation

  • Published:
LISP and Symbolic Computation

Abstract

Implementations of lazy evaluation for nonstrict functional languages usually involve the notion of a delayed representation of the value of an expression, which we call athunk. We present several techniques for implementing thunks and formalize a class of optimizations that reduce both the space and time overhead of these techniques. The optimizations depend on a compile-time inferencing strategy calledpath analysis, a generalization of strictness analysis that uncovers order-of-evaluation information. Although the techniques in this paper are focused on the compilation of a nonstrict functional language for a conventional architecture, they are directly applicable to most of the virtual machines commonly used for implementing such languages. The same techniques also apply to other forms of delayed evaluation such asfutures andpromises.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

References

  1. Abramsky, S., and Hankin, C.Abstract Interpretation of Declarative Languages, Ellis Horwood, 1987.

  2. Bloss, A.Path Analysis: Using Order-of-Evaluation Information to Optimize Lazy Functional Languages, Ph.D. thesis, Department of Computer Science, Yale University, New Haven, CT, 1988.

    Google Scholar 

  3. Bloss, A., and Hudak, P. Path semantics. InProceedings, Third Workshop on the Mathematical Foundations of Programming Language Semantics, Springer-Verlag LNCS, April 1987.

  4. Burn, G. L., Hankin, C. L., and Abramsky, S. The theory of strictness analysis for higher order functions. InLNCS 217: Programs as Data Objects, Springer-Verlag, New York, 1985, pp. 42–62.

    Google Scholar 

  5. Cousot, P., and Cousot, R. Abstract interpretation: A unified lattice model for static analysis of programs by construction or approximation of fixpoints. In4th ACM Sym. on Prin. of Prog. Lang., ACM, 1977, pp. 238–252.

  6. Fairbairn, J., and Wray, S. Tim: A simple, lazy abstract machine to execute super-combinators. InProceedings of 1987 Functional Programming Languages and Computer Architecture Conference, Springer-Verlag LNCS 274, September 1987, pp. 34–45.

  7. Hall, C. B., Wise, D. S. Compiling strictness into streams. InProceedings of the 14th ACM Symposium on Principles of Programming Languages, ACM, January 1987, pp. 132–143.

  8. Halstead, R. H., Jr. Multilisp: A language for concurrent symbolic computation.ACM Transactions on Programming Languages and Systems,7(4) (1985) 501–538.

    Google Scholar 

  9. Henderson, P.Functional Programming: Application and Implementation, Prentice-Hall, Englewood Cliffs, NJ, 1980.

    Google Scholar 

  10. Hudak, P.ALFL Reference Manual and Programmer's Guide. Research Report YALEU/DCS/RR-322, 2d ed., Yale University, New Haven, CT, October 1984.

    Google Scholar 

  11. Hudak, P., and Young, J. Higher-order strictness analysis for untyped lambda calculus. In12th ACM Sym. on Prin. of Prog. Lang., January 1986, pp. 97–109.

  12. Hudak, P., and Young, J. Collecting interpretations of expressions (without powerdomains). InProceedings of the 15th ACM Symposium on Principles of Programming Languages, January 1988, pp. 107–118.

  13. Hughes, J. Strictness detection in non-flat domains. InLNCS 217: Programs as Data Objects, Springer-Verlag, New York, 1986, pp. 42–62.

    Google Scholar 

  14. Johnsson, T. Efficient compilation of lazy evaluation. InProceedings of the SIG-PLAN 86 Symposium on Compiler Construction, ACM,SIGPLAN Notices 19(6) (June 1984), 58–69.

  15. Jones, N. D., and Muchnick, S. S. Complexity of flow analysis, inductive assertion synthesis, and a language due to dijkstra. InProgram Flow Analysis: Theory and Applications, Prentice-Hall, Englewood Cliffs, NJ, 1981, pp. 380–393.

    Google Scholar 

  16. Jones, S. P.The Implementation of Functional Programming Languages. Prentice-Hall, Englewood Cliffs, NJ, 1987.

    Google Scholar 

  17. Kieburtz, R. B.The G-Machine: A Fast, Graph-Reduction Evaluator. Technical Report CS/E-85-002, Dept. of Computer Science, Oregon Graduate Center, January 1985.

  18. Kranz, D., Kelsey, R., Rees, J., Hudak, P., Philbin, J., and Adams, N. Orbit: An optimizing compiler for Scheme. InSIGPLAN '86 Symposium on Compiler Construction, ACM, June 1986, pp. 219–233; published asSIGPLAN Notices 21(7) (July 1986).

  19. Liskov, B. Private communication, October 1987.

  20. Mauny, M., and Suárez, A. Implementing functional languages in the categorical abstract machine. InProceedings 1986 ACM Conference on Lisp and Functional Programming, Cambridge, MA, August 1986, pp. 266–278.

  21. Mycroft, A. The theory and practice of transforming call-by-need into call-by-value. InProceedings, of Int. Sym. on Programming, Springer-Verlag LNCS Vol. 83, 1980, pp. 269–281.

  22. The revised3 report on the algorithmic language scheme.SIGPLAN Notices 21(12) (December 1986), 37–79.

    Google Scholar 

  23. Turner, D. A. A new implementation technique for applicative languages.Software—Practice and Experience 9 (1979), 31–49.

    Google Scholar 

  24. Wadler, P., and Hughes, R. J. M. Projections for strictness analysis. InProceedings of 1987 Functional Programming Languages and Computer Architecture Conference, Springer Verlag LNCS 274, September 1987, pp. 385–407.

  25. Young, J.Theory and Practice of Semantics-Directed Compiling for Functional Programming Languages. Ph.D. thesis, Department of Computer Science, Yale University, New Haven, CT, 1988.

    Google Scholar 

  26. Young, J., and Hudak, P.Finding Fixpoints on Function Spaces. Research Report YALEU/DCS/RR-505, Department of Computer Science, New Haven, CT, November 1986.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Additional information

This research was supported in part by the National Science Foundation under Grant DCR-8451415.

Rights and permissions

Reprints and permissions

About this article

Cite this article

Bloss, A., Hudak, P. & Young, J. Code optimizations for lazy evaluation. Lisp and Symbolic Computation 1, 147–164 (1988). https://doi.org/10.1007/BF01806169

Download citation

  • Issue Date:

  • DOI: https://doi.org/10.1007/BF01806169

Keywords

Navigation