Corpus ID: 33647441

Closures in Lua

  title={Closures in Lua},
  author={Roberto Ierusalimschy and Luiz Henrique de Figueiredo and Waldemar Celes},
First-class functions are a very powerful language construct and a fundamental feature in functional languages. However, few procedural languages support this feature, due to their stack-based implementation. In this paper we discuss a new algorithm for the implementation of first-class functions used in the implementation of Lua 5.x. Unlike previous techniques, our algorithm does not need static analysis of the source code (a luxury that the on-the-fly Lua code generator cannot afford) and… Expand

Figures from this paper


Rabbit: A Compiler for Scheme
A compiler for the lexically-scoped dialect of LISP known as SCHEME, which handles only a small basis set which reflects the semantics of lambda-calculus, and serves to produce code as good as that produced by more traditional compilers. Expand
Efficient and safe-for-space closure conversion
This paper presents a new algorithm that exploits the use of compile-time control and data-flow information to optimize funtion calls and adopts the strong safe-for-space-complexity rule, thus achieving good asymptotic space usage. Expand
Space-efficient closure representations
This work has a new algorithm that exploits the use of compile-time control and data flow information to optimize closure representations and satisfies the strong “safe for space complexity” rule, thus achieving good asymptotic space usage. Expand
Lua-An Extensible Extension Language
Lua presents a mechanism offallbacks that allows programmers to extend the semantics of the language in some unconventional ways, as a noteworthy example, fallbacks allow the user to add different kinds of inheritance to the language. Expand
The Evolution of an Extension Language: A History of Lua
The trajectory of Lua is described, from its creation as an in-house language for two specific projects, until Lua 4.0, released in November 2000, which discusses the evolution of some of its concepts and the main landmarks in its evolution. Expand
Compiling a functional language
This paper summarizes the author's experience in implementing a compiler for a functional language, ML, which was first implemented in 1980 as a personal project when he was a postgraduate student at the University of Edinburgh. Expand
Coroutines in Lua
This paper presents and discusses the corou- tine facilities provided by the language Lua, a full implementation of the concept of asymmetric coroutines, and shows that this powerful construct supports easy and succint implementations of useful control behaviors. Expand
ORBIT: an optimizing compiler for scheme
Orbit was an optimizing compiler for T, a dialect of Scheme, that directly spawned six PhD theses and one Masters thesis, and influenced many other projects as well, including SML of New Jersey. Expand
The Implementation of Lua 5.0
We discuss the main novelties of the implementation of Lua 5.0: its register- based virtual machine, the new algorithm for optimizing tables used as arrays, the implementation of closures, and theExpand
Revisiting coroutines
This article introduces the concept of full asymmetric coroutines and provides a precise definition for it through an operational semantics, and demonstrates that full cor outines have an expressive power equivalent to one-shot continuations and one- shot delimited continuations. Expand