## Compilation as Metacomputation: Binding Time Separation in Modular Compilers (Extended Abstract) (1998)

Venue: | In 5th Mathematics of Program Construction Conference, MPC2000, Ponte de |

Citations: | 4 - 0 self |

### BibTeX

@INPROCEEDINGS{Harrison98compilationas,

author = {William L. Harrison and Samuel N. Kamin},

title = {Compilation as Metacomputation: Binding Time Separation in Modular Compilers (Extended Abstract)},

booktitle = {In 5th Mathematics of Program Construction Conference, MPC2000, Ponte de},

year = {1998}

}

### OpenURL

### Abstract

This paper presents a modular and extensible style of language specification based on metacomputations. This style uses two monads to factor the static and dynamic parts of the specification, thereby staging the specification and achieving strong binding-time separation. Because metacomputations are defined in terms of monads, they can be constructed modularly and extensibly using monad transformers. A number of language constructs are specified: expressions, control-flow, imperative features, block structure, and higher-order functions and recursive bindings. Metacomputation-style specification lends itself to semantics-directed compilation, which we demonstrate by creating a modular compiler for a higher-order, imperative, Algol-like language.

### Citations

1363 | The Essence of Functional Programming
- Wadler
- 1992
(Show Context)
Citation Context ...taging is an instance of metacomputation. The main contribution of this paper is a modular and extensible method of staging denotational specifications based on metacomputations, formalized via monads=-=[7, 13, 16, 23]-=-. A style of Parsing Type Checking Code Generation compile Optimization Target Interpreter Updating Store Stack Manipulation s:Source t:Target Figure 1: Handwritten compiler as metacomputation languag... |

772 | Notions of computation and monads
- Moggi
- 1991
(Show Context)
Citation Context ...taging is an instance of metacomputation. The main contribution of this paper is a modular and extensible method of staging denotational specifications based on metacomputations, formalized via monads=-=[7, 13, 16, 23]-=-. A style of Parsing Type Checking Code Generation compile Optimization Target Interpreter Updating Store Stack Manipulation s:Source t:Target Figure 1: Handwritten compiler as metacomputation languag... |

638 |
Compiling with continuations
- Appel
- 1992
(Show Context)
Citation Context ...ow [ Eq Block structure [ Eq Booleans Source Code: new x in new y in x := 5; y := 1; while (1sx) do y := y*x; x := x-1; Target Code: 0 := 5; 2: 2 := [1]; 3: halt; 1 := 1; 3 := [0]; jump 1; 1 := [2] * =-=[3]-=-; 2 := [0]; 1: 2 := 1; 3 := 1; 3 := [0]; 0 := [2] - [3] BRLEQ [2] [3] 2 3; jump 1; Figure 11: Compiler for While language and example compilation For the control flow language: Comp = T St Label Id; a... |

500 | Denotational Semantics: The Scott-Strachey Approach to Programming Language Semantics - Stoy - 1977 |

250 | Monad Transformers and Modular Interpreters
- Liang, Hudak, et al.
(Show Context)
Citation Context ...taging is an instance of metacomputation. The main contribution of this paper is a modular and extensible method of staging denotational specifications based on metacomputations, formalized via monads=-=[7, 13, 16, 23]-=-. A style of Parsing Type Checking Code Generation compile Optimization Target Interpreter Updating Store Stack Manipulation s:Source t:Target Figure 1: Handwritten compiler as metacomputation languag... |

209 | Continuation-based partial evaluation - Lawall, Danvy - 1994 |

199 | A modal analysis of staged computation - Davies, Pfenning |

160 |
Denotational semantics
- Mosses
- 1990
(Show Context)
Citation Context ...at the meaning of [[\Gamma]] can be reinterpreted in a variety of monads. Monadic semantics separate the description of a language from its denotation. In this sense, it is similar to action semantics=-=[17]-=- and high-level semantics[11]. The simplest monad is the identity monad, shown in Figure 3. Given the identity monad, we can define add as ordinary addition. [[\Gamma]] would have type Expression ! in... |

142 |
Modern Compiler Implementation in ML
- Appel
- 1998
(Show Context)
Citation Context ...ge over the monolithic approach. Consider the three definitions of the conditional if-then statement in Figure 6. The first is a dual continuation "control-flow" semantics, found commonly in=-= compilers[2]-=-. If B is true, then the first continuation,s[[c]] ? E , is executed, otherwise c is skipped and justsis executed. A more implementationoriented (informal) specification might be: [[if b then c]] = [[... |

54 |
Realistic Compiler Generation
- Lee
- 1989
(Show Context)
Citation Context ...can be reinterpreted in a variety of monads. Monadic semantics separate the description of a language from its denotation. In this sense, it is similar to action semantics[17] and high-level semantics=-=[11]-=-. The simplest monad is the identity monad, shown in Figure 3. Given the identity monad, we can define add as ordinary addition. [[\Gamma]] would have type Expression ! int . Perhaps the best known mo... |

52 | Deriving target code as a representation of continuation semantics - Wand - 1982 |

38 | Semantic Lego
- Espinosa
- 1995
(Show Context)
Citation Context |

38 | Compilers and staging transformations - Jørring, Scherlis - 1986 |

33 |
Separating binding times in language specifications
- Mogensen
- 1989
(Show Context)
Citation Context ... to code generation for a typed -calculus, and Nielson[19] presents an algorithm for static analysis of a typed -calculus which converts one-level specifications into twolevel specifications. Mogensen=-=[15]-=- generalizes this algorithm to handle variables of mixed binding times. The present work offers a semantic alternative to the two-level -calculus. We formalize distinct levels (in the sense of Nielson... |

30 | Modular Monadic Semantics and Compilation - Liang - 1998 |

29 |
Automatic binding time analysis for a typed l calculus
- Nielson, Nielson
- 1988
(Show Context)
Citation Context ...ince he does not compile to machine language, many of the issues we confront---especially staging---do not arise. A syntactic form of metacomputation can be found in the two-level -calculus of Nielson=-=[19]-=-. Two-level -calculus contains two distinct -calculi---representing the static and dynamic levels. Expressions of mixed level, then, have strongly separated binding times by definition. Nielson[18] ap... |

24 | Semantics-based compiling: A case study in typedirected partial evaluation
- Danvy, Vestergaard
- 1996
(Show Context)
Citation Context ...ty, extensibility, and modularity). While our binding time analysis is not automatic as in [19, 15], we consider a far wider range of programming language features than they do. Danvy and Vestergaard =-=[5] show how to produce code that-=- "looks like" machine language, by expressing the source language semantics in terms of machine language-like combinators (e.g., "popblock", "push"). When the interpreter... |

20 | Modular Compilers Based on Monad Transformers
- Harrison, Kamin
- 1998
(Show Context)
Citation Context ... monad. When composing T St Sto with itself, as above, the operations on the "inner" state need to be lifted through the outer state monad; this is the main technical issue in [7, 13]. In ou=-=r work in [8], we found-=- it convenient to factor the state monad into two parts: the state proper and the address allocator. This was really a "staging transformation," with the state monad representing dynamic com... |

10 |
Using functor categories to generate intermediate code
- Reynolds
- 1995
(Show Context)
Citation Context ...we include some building blocks not given in [8], specifically optimized expressions and procedures. (These will be included in the full paper.) Together these give us the entire language of Reynolds =-=[21]-=- with essentially the same code generated there (but with jumps and labels, avoiding the potential for infinite programs). The next section reviews the most relevant related work. In Section 3, we rev... |

7 |
A modular semantics for compiler generation
- Liang
- 1995
(Show Context)
Citation Context ...lly, Section 6 summarizes this work and outlines future research. 2 Related work Espinosa [7] and Hudak, Liang, and Jones [13] use monad transformers to create modular, extensible interpreters. Liang =-=[12, 14]-=- addresses the question of whether compilers can be developed similarly, but since he does not compile to machine language, many of the issues we confront---especially staging---do not arise. A syntac... |

4 |
The Essence of Algol," Algorithmic Languages
- Reynolds
- 1981
(Show Context)
Citation Context ...ompiler building block for this language appears in Figure 9. The static part of this specification allocates a free stack location a, and the program variable x is bound to an accepter-expresser pair=-=[20]-=- in the current environment ae. In an accepter-expresser pair hacc; expi, acc accepts an integer value and sets the value of its variable to the value, and the expresser exp simply returns the current... |

2 |
Code Generation from two-level denotational metalanguages
- Nielson, Nielson
- 1986
(Show Context)
Citation Context ...son[19]. Two-level -calculus contains two distinct -calculi---representing the static and dynamic levels. Expressions of mixed level, then, have strongly separated binding times by definition. Nielson=-=[18]-=- applies two-level -calculus to code generation for a typed -calculus, and Nielson[19] presents an algorithm for static analysis of a typed -calculus which converts one-level specifications into twole... |