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

Transplanting of Environments between Closures in the lambda calculus

Published: 20 June 2023 Publication History

Abstract

In programming languages, a function closure is a function whose body includes possibly free variables and that is accompanied by association with their values. The association of variables with their values is called an environment. If a programming language uses lexical scope and treats functions as first-class objects, then function closures are mandatory. Function closures are provided in Common Lisp, Emacs Lisp, Scheme and other dialects of LISP, as well as in modern scripting languages such as Python, JavaScript and Ruby, and procedural languages such as C++.
In our previous paper, we proposed a mechanism that enables us to extract an environment part from a function closure. However, it brings a situation that environments must be handled as a first-class object, which is a huge extension of the traditional theory to be avoid if possible, since several desirable properties will be lost.
This paper presents a method for replacing the environment of a function closure in the lambda calculus with the environment of another function closure.
By taking this approach rather than extracting the environment from the function closure and using it, it ise to avoid treating the environment directly as a first-class object.
We introduce a new computational system called lambda calculus with environment transplantation to explore the theoretical aspects of this process. Our system is defined by its syntax and reduction rules, and we provide a semantics for it through a transformation to the lambda calculus with records. The soundness of the reduction is demonstrated within this transformation semantics. Additionally, we give a simple type system to our calculus and show its subject reduction system.

References

[1]
M. Abadi, L. Cardelli, P-.L. Curien, and J.-J. Lévy. 1991. Explicit Substitutions. Journal of Functional Programming 1, 4 (October 1991), 375–416.
[2]
Andrej Bauer and Matijab Pretnar. 2015. Programming with algebraic effects and handlers. Journal of Logical and Algebraic Methods in Programming 84, 1 (January 2015), 108–123.
[3]
Stroustrup Bjarne. 2013. C++ Programming Languagee, Fourth Edition. Addison-Wesley Professional.
[4]
Pierre-Louis Curien, Thérèse Hardin, and Jean-Jacques Lévy. 1996. Confluence properties of weak and strong calculi of explicit substitutions. Journal of the ACM 43, 2 (March 1996), 362–397.
[5]
N. G. de Bruijn. 1972. Lambda calculus notation with nameless dummies, a tool for automatic formula manipulation, with application to the Church-Rosser theorem. Indagationes Mathematicae 75, 5 (1972), 381–392.
[6]
James Gosling, Bill Joy an Guy L. Steele, Gilad Bracha, and Alex Buckley. 2014. The Java Language Specification, Java SE 8 Edition. Addison-Wesley Professional.
[7]
Hiroki Joko and Shin ya Nishizaki. 2017. First-class Environments in Categorical Combinators. In Thoery and Practice of Computation. 28–43. https://doi.org/10.1142/9789813234079_0003
[8]
Gilles Kahn. 1987. Natural Semantics. In STACS 87(Lecture Notes in Computer Science, Vol. 247). Springer-Verlag, Berlin, Heidelberg, 22–39.
[9]
Ryotaro Kasuga and Shin-ya Nishizaki. 2022. Formalizing dynamic-wind in the lambda calculs. In ICSCA 2022: 2022 11th International Conference on Software and Computer Applications. ACM, New York, NY, United States, 90–96. https://doi.org/10.1145/3524304.3524318
[10]
Bil Lewis, Dan LaLiberte, and Richard Stallman. 2021. GNU Emacs Lisp Reference Manual For Emacs Version 27.2. https://www.gnu.org/software/emacs/manual/elisp.html.
[11]
Shin-ya Nishizaki. 1995. Simply Typed Lambda Calculus with First-class Environments. Publications of Research Institute for Mathematical Sciences Kyoto University 30, 6 (1995), 1055–1121. https://doi.org/10.2977/prims/1195164948
[12]
Shin-ya Nishizaki. 2000. A Polymorphic Environment Calculus and its Type Inference Algorithm. Higher-Order and Symbolic Computation 13 (2000), 239–278.
[13]
Shin-ya Nishizaki. 2013. Evaluation Strategy and Translation of Environment Calculus. In Information Computing and Applications. Springer Berlin Heidelberg, 232–242. https://doi.org/10.1007/978-3-642-53932-9_23
[14]
Shin-ya Nishizaki and Mizuki Fujii. 2012. Strong reduction for typed lambda calculus with first-class environments. In Lecture Notes in Computer Science, Vol. 7473. Springer-Verlag Berlin Heidelberg, 632–639. https://doi.org/10.1007/978-3-642-34062-8_82
[15]
Shin-ya Nishizaki and Ryotaro Kasuga. 2021. Untyped lambda calculus with functionally referable environments. In ICSCA 2021: 2021 10th International Conference on Software and Computer Applications. ACM, New York, NY, United States, 100–104. https://doi.org/10.1145/3457784.3457798
[16]
Shin-ya Nishizaki and Yuta Takayanagi. 2022. Extracting Environments from Function Closure. In ICSCA 2022: 2022 11th International Conference on Software and Computer Applications. ACM, New York, NY, United States, 61–68. https://doi.org/10.1145/3524304.3524313
[17]
Gordon D. Plotkin. 1981. A Structural Approach to Operational Semantics. Technical Report DAIMI FN-19. Computer Science Department, Aarhus University.
[18]
Gordon D. Plotkin. 2004. The origins of structural operational semantics. The Journal of Logic and Algebraic Programming 60–61 (2004), 3–15.

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Other conferences
ICSCA '23: Proceedings of the 2023 12th International Conference on Software and Computer Applications
February 2023
385 pages
ISBN:9781450398589
DOI:10.1145/3587828
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 the author(s) 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: 20 June 2023

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. environment
  2. function closure
  3. functional programming language
  4. lambda calculus

Qualifiers

  • Research-article
  • Research
  • Refereed limited

Conference

ICSCA 2023

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • 0
    Total Citations
  • 30
    Total Downloads
  • Downloads (Last 12 months)9
  • Downloads (Last 6 weeks)1
Reflects downloads up to 08 Feb 2025

Other Metrics

Citations

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

HTML Format

View this article in HTML Format.

HTML Format

Figures

Tables

Media

Share

Share

Share this Publication link

Share on social media