Nothing Special   »   [go: up one dir, main page]

skip to main content
10.1145/277650.277719acmconferencesArticle/Chapter ViewAbstractPublication PagespldiConference Proceedingsconference-collections
Article
Free access

Proper tail recursion and space efficiency

Published: 01 May 1998 Publication History

Abstract

The IEEE/ANSI standard for Scheme requires implementations to be properly tail recursive. This ensures that portable code can rely upon the space efficiency of continuation-passing style and other idioms. On its face, proper tail recursion concerns the efficiency of procedure calls that occur within a tail context. When examined closely, proper tail recursion also depends upon the fact that garbage collection can be asymptotically more space-efficient than Algol-like stack allocation.Proper tail recursion is not the same as ad hoc tail call optimization in stack-based languages. Proper tail recursion often precludes stack allocation of variables, but yields a well-defined asymptotic space complexity that can be relied upon by portable programs.This paper offers a formal and implementation-independent definition of proper tail recursion for Scheme. It also shows how an entire family of reference implementations can be used to characterize related safe-for-space properties, and proves the asymptotic inequalities that hold between them.

References

[1]
A. Aiken, M. F'~i/mdrich, and R. Levien. Better static memory management: Improving region-based analysis of higher-order languages. In 1995 Conference on Programming Language Design and Implementation, pages 174-185, San Diego, California, June 1995.
[2]
Andrew W. Appel. Compiling with Continuations. Cambridge University Press, 1992.
[3]
Andrew W. Appel and Zhong Sham. An empirical and analytic study of stack vs. heap cost for languages with closures. Journal of Functional Programming, 6(1):47-74, 1996.
[4]
Henry Baker. Cons should not cons its arguments, part Ih Cheney on the M.T.A. A CM SIGPLAN Notices, 30(9):17-20, September 1995.
[5]
Hans-Juergen Boehm. Space-efficient conservative garbage collection. In Proc. 1993 A CM Conference on Programming Language Design and Implementation, pages 197-206, 1993.
[6]
William D. Clinger and Lars Thomas Hansen. Lambda, the ultimate label, or a simple optimizing compiler for Scheme. In Proc. 199~ A CM Symposium on Lisp and Functional Programming, pages 128-139, 1994.
[7]
David R. Chase. Safety considerations for storage allocation optimizations. In Proc. 1988 A CM Conference on Programming Language Design and Implementation, pages 1-10, 1988.
[8]
William Clinger. The Scheme 311 compiler: an exercise in denotational semantics. In Proc. 198~ A CM Symposium on Lisp and Functional Programming, pages 356-364, August 1984.
[9]
Thomas H. Cormen, Charles E. Leiserson, and Ronald L. Rivest. Introduction to Algorithms. MIT Press/McGraw-Hill, 1990.
[10]
Christopher W. Fraser and David R. Hanson. A Retargetable C Compiler: Design and Implementation. Benjamin/Cummings, 1995.
[11]
Michael J. Fischer. Lambda calculus schemata. In Proceedings of the A CM Conference on Proving Assertions about Programs, pages 104-109. ACM SIGPLAN, SIGPLAN Notices, Vol. 7, No 1 and SIGACT News, No 14, January 1972.
[12]
Comae Flanagan, Amr Sabry, Bruce F. Duba, and Matthias Felleisen. The essence of compiling with continuations. In Proc. 1993 A CM Conference on Programming Language Design and Implementation, pages 237-247, 1993.
[13]
Joshua D. Guttman and Mitchell Wand (editors). VLISP: A Verified Implementation of Scheme. Kluwer, Boston, 1995. Originally published as a special double issue of the journal Lisp and Symbolic Computation (Volume 8, Issue 1/2).
[14]
Chris Hanson. Efficient stack allocation for tailrecursive languages. In Proc. i990 A CM Symposium on Lisp and Functional Programming, 1990.
[15]
Carl Hewitt. Viewing control structures as patterns of passing messages. Artificial Intelligence, 8:323-364, 1977.
[16]
IEEE Computer Society, New York. IEEE Standard for the Scheme Programming Lan. guage, IEEE standard 1178-1990 edition, 1991.
[17]
Richard Kelsey, William Clinger, and Jonathan Rees (eds.). Revised5 report on the algorithmic language Scheme. ftr://ftr. nj. nee. com/pub/kel sey/rSrs, ps, February 1998.
[18]
David A. Kranz, Richard Kelsey, Jonathan A. Rees, Paul Hudak, James Philbin, and Norman I. Adams. Orbit: An optimizing compiler for Scheme. In Proceedings SIGPLAN '86 Symposium on Compiler Construction, 1986. SIG. PLAN Notices 21 (7), July, 1986, 219-223.
[19]
Donald A. Knuth. The Art of Programming, Volume 1 /Fundamental Algorithms. Addison- Wesley, Boston, second edition, 1973.
[20]
Lightship Software. MacScheme Manual and Software. The Scientific Press, 1990.
[21]
Greg Morrisett, Matthias Felleisen, and Robert Haxper. Abstract models of memory management. In Proc. 1995 A CM Conference on Functional Programming and Computer Architecture, pages 66-77, 1995.
[22]
G. Morrisett and R. Harper. Semantics of memory management for polymorphic languages. In A. D. Gordon and A. M. Pitts, editors, Higher Order Operational Techniques in Semantics, Publications of the Newton Institute, pages 175-226. Cambridge University Press, 1997.
[23]
Hanne Riis Nielson and Flemming Nielson. Semantics with Applications: a Formal Introduction. John Wiley & Sons, 1992.
[24]
Christian Queinnec. Lisp in Small Pieces. Cambridge University Press, 1996.
[25]
John D. Ramsdell. Scheme: the next generation. ACId Lisp Pointers, 7(4):13-14, Oct-Dee 1994.
[26]
John D. RamsdeIl. The tail recursive SECD machine. To appear, 1998.
[27]
Manuel Serrano. Bigloo user's manual. Part of the Bigloo 1.9 distribution available via httr: / / cuiww~, uni ge. ch/~e rrano/b igloo, html, 1997.
[28]
Manuel Serrano and Marc Feeley. Storage use analysis and its applications. In Proc. 1996 A CM International Conference on Functional Programming, pages 50-61, 1996.
[29]
Jeffrey Mark Siskind. Stalin - a STAtic Language ImplementatioN. Software available via http://w~, neci .nj .nec. com/homepages/qobi/, 1997.
[30]
Gerald J. Sussman and Guy L. Steele, Jr. Scheme: An interpreter for extended lambda calculus. Artificial Intelligence Memo 349, Mas* sachusetts Institute of Technology, Cambridge, MA, December 1975.
[31]
Guy L. Steele, Jr. and Gerald Jay Sussman. Lambda: The ultimate imperative. Artificial Intelligence Memo 353, Massachusetts Institute of Technology, Cambridge, MA, March 1976.
[32]
Guy L. Steele: Jr. and Gerald Jay Sussman. The art of the interpreter or, the modularity complex (parts zero, one and two). Artificial Intelligence Memo 453, Massachusetts institute of Technology, Cambridge, MA, May 1978.
[33]
Guy L. Steele, Jr. and Gerald Jay Sussman. The revised report on SCHEME. Artificial Intelligence Memo 452, Massachusetts Institute of Technology, Cambridge~ MA, January 1978.
[34]
Guy L. Steele, Jr. Lambda: The ultimate declarative. Artificial Intelligence Memo 379, Massachusetts Institute of Technology, Cambridge, MA, October 1976.
[35]
Guy Lewis Steele, Jr. Debunking the "expensive procedure call" myth. In ACM National Conference, pages 153-162, Seattle, October 1977. Revised as MIT AI Memo 443, October 1977.
[36]
Guy L. Steele, Jr. Rabbit: A compiler for Scheme. Technical Report 474, Massachusetts Institute of Technology, Cambridge, MA, May 1978.
[37]
Mads Torte and Jean-Pierre Talpin. Implementation of the typed call-by-value A-calculus using a stack of regions. In Proceedings 21st Annual A CM Symposium on Principles of Programming Languages, pages 188-201, 1994.
[38]
Mitchell Wand. Continuation-based program transformation strategies. Journal of the A CM, 27:164-180, 1980.
[39]
Mitchell Wand and Daniel P. Friedman. Compiling larnbda expressions using continuations and factorizations. Journal of Computer Languages, 3:241-263, 1978.

Cited By

View all
  • (2024)Designing Restartable Exception Handling Mechanisms for Implementing Efficient and Safe High-level LanguagesJournal of Information Processing10.2197/ipsjjip.32.43632(436-450)Online publication date: 2024
  • (2024)Oxidizing OCaml with Modal Memory ManagementProceedings of the ACM on Programming Languages10.1145/36746428:ICFP(485-514)Online publication date: 15-Aug-2024
  • (2023)Capturing Invalid Input Manipulations for Memory Corruption DiagnosisIEEE Transactions on Dependable and Secure Computing10.1109/TDSC.2022.314502220:2(917-930)Online publication date: 1-Mar-2023
  • Show More Cited By

Recommendations

Comments

Please enable JavaScript to view thecomments powered by Disqus.

Information & Contributors

Information

Published In

cover image ACM Conferences
PLDI '98: Proceedings of the ACM SIGPLAN 1998 conference on Programming language design and implementation
May 1998
357 pages
ISBN:0897919874
DOI:10.1145/277650
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 01 May 1998

Permissions

Request permissions for this article.

Check for updates

Qualifiers

  • Article

Conference

PLDI98
Sponsor:
PLDI98: Conference on Programming Language
June 17 - 19, 1998
Quebec, Montreal, Canada

Acceptance Rates

PLDI '98 Paper Acceptance Rate 31 of 136 submissions, 23%;
Overall Acceptance Rate 406 of 2,067 submissions, 20%

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)174
  • Downloads (Last 6 weeks)32
Reflects downloads up to 18 Nov 2024

Other Metrics

Citations

Cited By

View all
  • (2024)Designing Restartable Exception Handling Mechanisms for Implementing Efficient and Safe High-level LanguagesJournal of Information Processing10.2197/ipsjjip.32.43632(436-450)Online publication date: 2024
  • (2024)Oxidizing OCaml with Modal Memory ManagementProceedings of the ACM on Programming Languages10.1145/36746428:ICFP(485-514)Online publication date: 15-Aug-2024
  • (2023)Capturing Invalid Input Manipulations for Memory Corruption DiagnosisIEEE Transactions on Dependable and Secure Computing10.1109/TDSC.2022.314502220:2(917-930)Online publication date: 1-Mar-2023
  • (2023)Neural-FEBIJournal of Systems and Software10.1016/j.jss.2023.111627199:COnline publication date: 1-May-2023
  • (2021)Corpse reviver: sound and efficient gradual typing via contract verificationProceedings of the ACM on Programming Languages10.1145/34343345:POPL(1-28)Online publication date: 4-Jan-2021
  • (2020)Evolution of Emacs LispProceedings of the ACM on Programming Languages10.1145/33863244:HOPL(1-55)Online publication date: 12-Jun-2020
  • (2020)PatchScope: Memory Object Centric Patch DiffingProceedings of the 2020 ACM SIGSAC Conference on Computer and Communications Security10.1145/3372297.3423342(149-165)Online publication date: 30-Oct-2020
  • (2019)Evaluating Portable Mechanisms for Legitimate Execution Stack Access with a Scheme Interpreter in an Extended SC LanguageJournal of Information Processing10.2197/ipsjjip.27.17727(177-189)Online publication date: 2019
  • (2019)A space-efficient call-by-value virtual machine for gradual set-theoretic typesProceedings of the 31st Symposium on Implementation and Application of Functional Languages10.1145/3412932.3412940(1-12)Online publication date: 25-Sep-2019
  • (2019)Abstracting algebraic effectsProceedings of the ACM on Programming Languages10.1145/32903193:POPL(1-28)Online publication date: 2-Jan-2019
  • Show More Cited By

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Login options

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media