skip to main content
10.1145/3524304.3524318acmotherconferencesArticle/Chapter ViewAbstractPublication PagesicscaConference Proceedingsconference-collections
research-article

Formalizing dynamic-wind in the lambda calculus

Authors Info & Claims
Published:06 June 2022Publication History

ABSTRACT

The Scheme programming language has the control constructs: call-with-current-continuation (call/cc) and dynamic-wind. The construct call/cc is a procedure to handle first-class continuations. The construct dynamic-wind is a procedure to hook a continuation captured by call/cc. It can add pre- and post-processing to a continuation, and allows flexible handling of global escape and control effect by continuation calls. The first example where the continuation is applied is rewriting variables with dynamic scope, and the second is saving and restoring registers during context switching of threads implemented in user space.

On the other hand, dynamic-wind is very difficult to understand in Scheme. In fact, the semantics of dynamic-wind represent one of the most complicated mechanisms in Scheme. The semantics presented in the revised Scheme language definition remain complicated, and it is difficult to understand the behavior and write programs correctly. In this article, we focus on three main uses of dynamic-wind: resource allocation at continuous invocation time, and resource release at global escape time. The use of dynamic-wind is focused on resource management, and formalize resource state and resource operations in this paper. For the dynamic-wind modeled in such a way, we propose a type system and an effect system to track the resource state.

In most of the discussions in this paper, we have simplified the model of dynamic-wind to clarify the theory. However, we will show that the method can be applied to more complex situations in practice.

References

  1. Yuta Aoyagi and Shin-ya Nishizaki. 2018. Untyped Call-by-Value Calculus with First-Class Continuations and Environments. In Theory and Practice of Computation. World Scientific, 101–117. doi:10.1142/9789813279674_0008.Google ScholarGoogle Scholar
  2. H. P. Barendregt. 2013. The Lambda Calculus: Its Sytax and Semantics Revised Edition. North Holland.Google ScholarGoogle Scholar
  3. Olivier Danvy and Andrzej Filinski. 1990. Abstracting Control. In Proceedings of the 1990 ACM Conference on LISP and Functional Programming (Nice, France) (LFP ’90). Association for Computing Machinery, New York, NY, USA, 151–160. https://doi.org/10.1145/91556.91622Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Marc Feeley. [n.d.]. Scheme Requests for Implementation: SFRI-39. https://srfi.schemers.org/srfi-39/srfi-39.html.Google ScholarGoogle Scholar
  5. Mattias Felleisen. [n.d.]. The Theory and Practice of First-Class Prompts. In Proceedings of the 15th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (New York, NY, USA, 1988) (POPL ’88). Association for Computing Machinery, 180–190. https://doi.org/10.1145/73560.73576 event-place: San Diego, California, USA.Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. M. Felleisen, D. P. Friedman, E. Kohlbecker, and B. Duba. 1986. Reasoning with continuations. In Proceedings of the Symposium on Logic in Computer Science. IEEE Computer Society Press.Google ScholarGoogle Scholar
  7. Matthias Felleisen, Daniel P. Friedman, Eugene Kohlbecker, and Bruce Duba. 1987. A syntactic theory of sequential control. Theoretical Computer Science 52, 3 (1987), 205–237. https://doi.org/10.1016/0304-3975(87)90109-5Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Martin Gasbichler, Eric Knauel, Michael Sperber, and R. Kelsey. [n.d.]. How to Add Threads to a Sequential Language Without Getting Tangled Up.Google ScholarGoogle Scholar
  9. J.-Y. Girard, P. Taylor, and Y. Lafont. 1989. Proofs and Types. Cambridge Tracts in Computer Science, Vol. 7. Cambridge University Press.Google ScholarGoogle Scholar
  10. T. G. Griffin. 1990. A Formulae-as-Types Notion of Control. In Conference Record of the Seventeenth Annual ACM Symposium on Principles of Programming Languages.Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Christopher T. Haynes and Daniel P. Friedman. [n.d.]. Embedding Continuations in Procedural Objects. 9, 4 ([n. d.]), 582–598. https://doi.org/10.1145/29873.30392 Place: New York, NY, USA Publisher: Association for Computing Machinery.Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Pierre Jouvelot and David Gifford. [n.d.]. Algebraic Reconstruction of Types and Effects. In Proceedings of the 18th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (New York, NY, USA, 1991) (POPL ’91). Association for Computing Machinery, 303–310. https://doi.org/10.1145/99583.99623 event-place: Orlando, Florida, USA.Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Oleg Kiselyov. [n.d.]. Implementations of delimited control in OCaml, Haskell, Scheme. https://okmij.org/ftp/continuations/implementations.html#dynamic-wind. https://okmij.org/ftp/continuations/implementations.html#dynamic-windGoogle ScholarGoogle Scholar
  14. Oleg Kiselyov, Chung-chieh Shan, and Amr Sabry. [n.d.]. Delimited Dynamic Binding. 41, 9([n. d.]), 26–37. https://doi.org/10.1145/1160074.1159808 Place: New York, NY, USA Publisher: Association for Computing Machinery.Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. S. Nishizaki. 1994. Programs with Continuations and Linear Logic. 21, 2 (1994), 165–190. Elsevier.Google ScholarGoogle Scholar
  16. S. Nishizaki. 1995. Simply Typed Lambda Calculus with First-class Environments. Publications of Research Institute for Mathematical Sciences Kyoto University 30, 6 (1995), 1055–1121.Google ScholarGoogle ScholarCross RefCross Ref
  17. Shin-ya Nishizaki. 2000. A Polymorphic Environment Calculus and its Type Inference Algorithm. Higher-Order and Symbolic Computation 13 (2000), 239–278. Springer.Google ScholarGoogle ScholarDigital LibraryDigital Library

Recommendations

Comments

Login options

Check if you have access through your login credentials or your institution to get full access on this article.

Sign in
  • Published in

    cover image ACM Other conferences
    ICSCA '22: Proceedings of the 2022 11th International Conference on Software and Computer Applications
    February 2022
    224 pages
    ISBN:9781450385770
    DOI:10.1145/3524304

    Copyright © 2022 ACM

    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]

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    • Published: 6 June 2022

    Permissions

    Request permissions about this article.

    Request Permissions

    Check for updates

    Qualifiers

    • research-article
    • Research
    • Refereed limited

PDF Format

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

HTML Format

View this article in HTML Format .

View HTML Format