A Rational Deconstruction of Landin’s SECD Machine
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.
Unable to display preview. Download preview PDF.
- 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)CrossRefGoogle 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-3Google 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-28Google 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
- 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
- 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-23Google 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 ProgrammingGoogle 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 , pp. 446–457Google 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)CrossRefGoogle Scholar
- 23.Hatcliff, J., Danvy, O.: A generic account of continuation-passing styles. In: Boehm , pp. 458–471Google Scholar
- 24.Hein, P.: Grooks. MIT Press, Cambridge (1966)Google Scholar
- 26.Krivine, J.-L.: Un interprète du λ-calcul. Brouillon (1985), Available online at, http://www.pps.jussieu.fr/~krivine
- 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
- 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
- 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-145Google 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-474Google 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