Skip to main content
Log in

Fixing Letrec: A Faithful Yet Efficient Implementation of Scheme's Recursive Binding Construct

  • Published:
Higher-Order and Symbolic Computation

Abstract

A Scheme letrec expression is easily converted into more primitive constructs via a straightforward transformation given in the Revised5 Report. This transformation, unfortunately, introduces assignments that can impede the generation of efficient code. This article presents a more judicious transformation that preserves the semantics of the revised report transformation and also detects invalid references and assignments to left-hand-side variables, yet enables the compiler to generate efficient code. A variant of letrec that enforces left-to-right evaluation of bindings is also presented and shown to add virtually no overhead.

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. Bondorf, A. Similix Manual, System Version 5.0. DIKU, University of Copenhagen, Denmark, 1993.

  2. Bose, B. DDD—A transformation system for digital design derivation. Technical Report 331, Computer Science Dept., Indiana Univ., Bloomington, Ind., May 1991.

  3. Burger, R.G. The Scheme machine. Technical Report 413, Computer Science Dept., Indiana Univ., Bloomington, Ind., August 1994.

  4. Dybvig, R. K., Hieb, R., and Bruggeman, C. Syntactic abstraction in Scheme. Lisp and Symbolic Computation, 5(4) (1993) 295–326.

    Article  Google Scholar 

  5. Feeley, M., Turcotte, M., and Lapalme, G. Using Multilisp for solving constraint satisfaction problems: An application to nucleic acid 3D structure determination. Lisp and Symbolic Computation, 7 (1994) 231–247.

    Article  Google Scholar 

  6. Gabriel, R.P. Performance and Evaluation of LISP Systems. MIT Press Series in Computer Systems. MIT Press, Cambridge, Massachusetts, 1985.

  7. Kelsey, R., Clinger, W., and Rees, J. Revised5 report on the algorithmic language Scheme. Higher-Order and Symbolic Computation, 11(1) (1998) 7–105.

  8. Kranz, D.A., Orbit, An optimizing compiler for scheme. PhD thesis, Yale University, May 1988.

  9. Kranz, D.A., Kelsey, R., Rees, J.A., Hudak, P., Philbin, J., and Adams, N.I. Orbit: an optimizing compiler for Scheme. SIGPLAN Notices, ACM Symposium on Compiler Construction, 21(7) (1986) 219–233.

  10. Rees, J.A., Adams, N.I., and Meehan, J.R. The T Manual. Yale University, New Haven, Connecticut, USA, 1984. Fourth edition.

  11. Rozas, G.J. Liar, an Algol-like compiler for Scheme, S.B. Thesis, Department of Electrical Engineering and Computer Science, Massachusetts Institute of Technology, January 1984.

  12. Rozas, G.J. Taming the Y operator. In Proceedings of the 1992 ACM Conference on Lisp and Functional Programming, San Francisco, USA, June 1992, pp. 226–234.

  13. Guy L. Steele Jr. Rabbit: A compiler for Scheme. MIT AI Memo 474, Massachusetts Institute of Technology, Cambridge, Mass., May 1978.

  14. Waddell, O. and Dybvig, R.K. Extending the scope of syntactic abstraction. In Conference Record of the Twenty Sixth Annual ACM Symposium on Principles of Programming Languages, January 1999, pp. 203–213.

  15. Waddell, O., Sarkar, D., and Dybvig, R.K. Robust and effective transformation of letrec. In Scheme 2002: Proceedings of the Third Workshop on Scheme and Functional Programming, October 2002.

  16. Wright, A.K. and Cartwright, R. A practical soft type system for scheme. In Proceedings of the 1994 ACM Conference on LISP and Functional Programming, 1994, pp. 250–262.

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Oscar Waddell.

Additional information

A preliminary version of this article was presented at the 2002 Workshop on Scheme and Functional Programming [15].

Rights and permissions

Reprints and permissions

About this article

Cite this article

Waddell, O., Sarkar, D. & Dybvig, R.K. Fixing Letrec: A Faithful Yet Efficient Implementation of Scheme's Recursive Binding Construct. Higher-Order Symb Comput 18, 299–326 (2005). https://doi.org/10.1007/s10990-005-4878-3

Download citation

  • Issue Date:

  • DOI: https://doi.org/10.1007/s10990-005-4878-3

Keywords

Navigation