Skip to main content

A Rational Deconstruction of Landin’s SECD Machine

  • Conference paper
Implementation and Application of Functional Languages (IFL 2004)

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 3474))

Included in the following conference series:

Abstract

Landin’s SECD machine was the first abstract machine for the λ-calculus viewed as a programming language. Both theoretically as a model of computation and practically as an idealized implementation, it has set the tone for the subsequent development of abstract machines for functional programming languages. However, and even though variants of the SECD machine have been presented, derived, and invented, the precise rationale for its architecture and modus operandi has remained elusive. In this article, we deconstruct the SECD machine into a λ-interpreter, i.e., an evaluation function, and we reconstruct λ-interpreters into a variety of SECD-like machines. The deconstruction and reconstructions are transformational: they are based on equational reasoning and on a combination of simple program transformations—mainly closure conversion, transformation into continuation-passing style, and defunctionalization.

The evaluation function underlying the SECD machine provides a precise rationale for its architecture: it is an environment-based eval-apply evaluator with a callee-save strategy for the environment, a data stack of intermediate results, and a control delimiter. Each of the components of the SECD machine (stack, environment, control, and dump) is therefore rationalized and so are its transitions.

The deconstruction and reconstruction method also applies to other abstract machines and other evaluation functions.

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

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Ager, M.S., Biernacki, D., Danvy, O., Midtgaard, J.: A functional correspondence between evaluators and abstract machines. In: Miller, D. (ed.) Proceedings of the Fifth ACM-SIGPLAN International Conference on Principles and Practice of Declarative Programming (PPDP 2003), pp. 8–19. ACM Press, New York (2003)

    Chapter  Google Scholar 

  2. Ager, M.S., Danvy, O., Goldberg, M.: A symmetric approach to compilation and decompilation. In: Mogensen, T.Æ., Schmidt, D.A., Sudborough, I.H. (eds.) The Essence of Computation. LNCS, vol. 2566, pp. 296–331. Springer, Heidelberg (2002)

    Chapter  Google Scholar 

  3. 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); Extended version available as the technical report BRICS-RS-04-3

    Google Scholar 

  4. Ager, M.S., Danvy, O., Midtgaard, J.: A functional correspondence between monadic evaluators and abstract machines for languages with computational effects. Theoretical Computer Science (2005); Accepted for publication. Extended version available as the technical report BRICS RS-04-28

    Google Scholar 

  5. Banerjee, A., Heintze, N., Riecke, J.G.: Design and correctness of program transformations based on control-flow analysis. In: Kobayashi, N., Pierce, B.C. (eds.) TACS 2001. LNCS, vol. 2215, pp. 420–447. Springer, Heidelberg (2001)

    Chapter  Google Scholar 

  6. Bell, J.M., Bellegarde, F., Hook, J.: Type-driven defunctionalization. In: Tofte, M. (ed.) Proceedings of the 1997 ACM SIGPLAN International Conference on Functional Programming, Amsterdam, The Netherlands, pp. 25–37. ACM Press, New York (1997)

    Chapter  Google Scholar 

  7. Biernacki, D., Danvy, O.: From interpreter to logic engine by defunctionalization. In: Bruynooghe, M. (ed.) LOPSTR 2003. LNCS, vol. 3018, pp. 143–159. Springer, Heidelberg (2004)

    Google Scholar 

  8. Boehm, H.-J. (ed.): Proceedings of the Twenty-First Annual ACM Symposium on Principles of Programming Languages, Portland, Oregon. ACM Press, New York (1994)

    Google Scholar 

  9. Danvy, O.: Back to direct style. Science of Computer Programming 22(3), 183–195 (1994)

    Article  MATH  MathSciNet  Google Scholar 

  10. Danvy, O.: Type-directed partial evaluation. In: Steele Jr., G.L. (ed.) Proceedings of the Twenty-Third Annual ACM Symposium on Principles of Programming Languages, St. Petersburg Beach, Florida, pp. 242–257. ACM Press, New York (1996)

    Google Scholar 

  11. Danvy, O.: A rational deconstruction of Landin’s SECD machine. Technical Report BRICS RS-03-33, DAIMI, Department of Computer Science, University of Aarhus, Aarhus, Denmark (October 2003)

    Google Scholar 

  12. Danvy, O., Filinski, A.: Abstracting control. In: Wand, M. (ed.) Proceedings of the 1990 ACM Conference on Lisp and Functional Programming, Nice, France, pp. 151–160. ACM Press, New York (1990)

    Chapter  Google Scholar 

  13. Danvy, O., Filinski, A.: Representing control, a study of the CPS transformation. Mathematical Structures in Computer Science 2(4), 361–391 (1992)

    Article  MATH  MathSciNet  Google Scholar 

  14. 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); Extended version available as the technical report BRICS RS-01-23

    Google Scholar 

  15. Danvy, O., Nielsen, L.R.: On one-pass CPS transformations. Technical Report BRICS RS-02-3, DAIMI, Department of Computer Science, University of Aarhus, Aarhus, Denmark (January 2002); Accepted for publication in the Journal of Functional Programming

    Google Scholar 

  16. Diehl, S., Hartel, P., Sestoft, P.: Abstract machines for programming language implementation. Future Generation Computer Systems 16, 739–751 (2000)

    Article  Google Scholar 

  17. Felleisen, M.: The Calculi of λ-v-CS Conversion: A Syntactic Theory of Control and State in Imperative Higher-Order Programming Languages. PhD thesis, Department of Computer Science, Indiana University, Bloomington, Indiana (August 1987)

    Google Scholar 

  18. Felleisen, M.: The theory and practice of first-class prompts. In: Ferrante, J., Mager, P. (eds.) Proceedings of the Fifteenth Annual ACM Symposium on Principles of Programming Languages, San Diego, California, pp. 180–190. ACM Press, New York (1988)

    Google Scholar 

  19. Felleisen, M., Flatt, M.: Programming languages and lambda calculi. Unpublished lecture notes (1989–2003), http://www.ccs.neu.edu/home/matthias/3810-w02/readings.html

  20. Filinski, A.: Representing monads. In: Boehm [8], pp. 446–457

    Google Scholar 

  21. Friedman, D.P., Wand, M., Haynes, C.T.: Essentials of Programming Languages, 2nd edn. MIT Press, Cambridge (2001)

    MATH  Google Scholar 

  22. Gasbichler, M., Sperber, M.: Final shift for call/cc: direct implementation of shift and reset. In: Peyton Jones, S. (ed.) Proceedings of the 2002 ACM SIGPLAN International Conference on Functional Programming, Pittsburgh, Pennsylvania. SIGPLAN Notices, vol. 37(9), pp. 271–282. ACM Press, New York (2002)

    Chapter  Google Scholar 

  23. Hatcliff, J., Danvy, O.: A generic account of continuation-passing styles. In: Boehm [8], pp. 458–471

    Google Scholar 

  24. Hein, P.: Grooks. MIT Press, Cambridge (1966)

    Google Scholar 

  25. Kameyama, Y., Hasegawa, M.: A sound and complete axiomatization of delimited continuations. In: Shivers, O. (ed.) Proceedings of the 2003 ACM SIGPLAN International Conference on Functional Programming, Uppsala, Sweden, pp. 177–188. ACM Press, New York (2003)

    Chapter  Google Scholar 

  26. Krivine, J.-L.: Un interprète du λ-calcul. Brouillon (1985), Available online at, http://www.pps.jussieu.fr/~krivine

  27. Landin, P.J.: The mechanical evaluation of expressions. The Computer Journal 6(4), 308–320 (1964)

    MATH  Google Scholar 

  28. Landin, P.J.: The next 700 programming languages. Commun. ACM 9(3), 157–166 (1966)

    Article  MATH  Google Scholar 

  29. Lawall, J.L., Danvy, O.: Continuation-based partial evaluation. In: Talcott, C.L. (ed.) Proceedings of the 1994 ACM Conference on Lisp and Functional Programming, Orlando, Florida. LISP Pointers, vol. VII(3), pp. 227–238. ACM Press, New York (1994)

    Chapter  Google Scholar 

  30. McCarthy, J., Abrahams, P.W., Edwards, D.J., Hart, T.P., Levin, M.I.: LISP 1.5 Programmer’s Manual. The MIT Press, Cambridge (1962)

    Google Scholar 

  31. Morris, L.: The next 700 formal language descriptions. Lisp and Symbolic Computation 6(3/4), 249–258 (1993)

    Article  Google Scholar 

  32. Nielsen, L.R.: A denotational investigation of defunctionalization. Technical Report BRICS RS-00-47, DAIMI, Department of Computer Science, University of Aarhus, Aarhus, Denmark (December 2000)

    Google Scholar 

  33. Peyton Jones, S.L.: Implementing lazy functional languages on stock hardware: The spineless tagless G-machine. Journal of Functional Programming 2(2), 127–202 (1992)

    Article  MATH  Google Scholar 

  34. Plotkin, G.D.: Call-by-name, call-by-value and the λ-calculus. Theoretical Computer Science 1, 125–159 (1975)

    Article  MATH  MathSciNet  Google Scholar 

  35. Ramsdell, J.D.: The tail-recursive SECD machine. Journal of Automated Reasoning 23(1), 43–62 (1999)

    Article  MathSciNet  Google Scholar 

  36. Reynolds, J.C.: The discoveries of continuations. Lisp and Symbolic Computation 6(3/4), 233–247 (1993)

    Article  Google Scholar 

  37. Reynolds, J.C.: Definitional interpreters for higher-order programming languages. Higher-Order and Symbolic Computation 11(4), 363–397 (1998); Reprinted from the proceedings of the 25th ACM National Conference (1972) (with a foreword)

    Google Scholar 

  38. Schmidt, D.A.: Denotational Semantics: A Methodology for Language Development. Allyn and Bacon, Inc., Boston (1986)

    Google Scholar 

  39. Shivers, O.: Control-Flow Analysis of Higher-Order Languages or Taming Lambda. PhD thesis, School of Computer Science, Carnegie Mellon University, Pittsburgh, Pennsylvania (May 1991), Technical Report CMU-CS-91-145

    Google Scholar 

  40. Steele Jr., G.L.: Lambda, the ultimate declarative. AI Memo 379, Artificial Intelligence Laboratory. Massachusetts Institute of Technology, Cambridge, Massachusetts (November 1976)

    Google Scholar 

  41. Steele Jr., G.L.: Rabbit: A compiler for Scheme. Master’s thesis, Artificial Intelligence Laboratory. Massachusetts Institute of Technology, Cambridge, Massachusetts (May 1978), Technical report AI-TR-474

    Google Scholar 

  42. Steele Jr., G.L., Sussman, G.J.: Lambda, the ultimate imperative. AI Memo 353, Artificial Intelligence Laboratory. Massachusetts Institute of Technology, Cambridge, Massachusetts (March 1976)

    Google Scholar 

  43. Steele Jr., G.L., Sussman, G.J.: The art of the interpreter or, the modularity complex (parts zero, one, and two). AI Memo 453, Artificial Intelligence Laboratory, Massachusetts Institute of Technology, Cambridge, Massachusetts (May 1978)

    Google Scholar 

  44. Stoy, J.E.: Denotational Semantics: The Scott-Strachey Approach to Programming Language Theory. MIT Press, Cambridge (1977)

    Google Scholar 

  45. Winskel, G.: The Formal Semantics of Programming Languages. Foundation of Computing Series. The MIT Press, Cambridge (1993)

    MATH  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2005 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Danvy, O. (2005). A Rational Deconstruction of Landin’s SECD Machine. In: Grelck, C., Huch, F., Michaelson, G.J., Trinder, P. (eds) Implementation and Application of Functional Languages. IFL 2004. Lecture Notes in Computer Science, vol 3474. Springer, Berlin, Heidelberg. https://doi.org/10.1007/11431664_4

Download citation

  • DOI: https://doi.org/10.1007/11431664_4

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-26094-3

  • Online ISBN: 978-3-540-32038-8

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics