## Online Type-Directed Partial Evaluation for Dynamically-Typed Languages (1999)

### Cached

### Download Links

Venue: | Computer Software |

Citations: | 6 - 1 self |

### BibTeX

@ARTICLE{Sumii99onlinetype-directed,

author = {Eijiro Sumii and Naoki Kobayashi},

title = {Online Type-Directed Partial Evaluation for Dynamically-Typed Languages},

journal = {Computer Software},

year = {1999},

volume = {17},

pages = {38--62}

}

### OpenURL

### Abstract

This article presents an alternative method of type-directed partial evaluation, which is simpler and more efficient than previous methods. Unlike previous methods, it is straightforwardly applicable to functional languages with various powerful type systems. As an extreme instance, this article mainly deals with a dynamically-typed functional language like Scheme. The key idea is to extend primitive value destructors such as function application and pair destruction (car and cdr), so that they generate residual code when their operands are dynamic. It unnecessitates an operation in type-directed partial evaluation called reflection, which was the major cause of complication and inefficiency in previous methods. We formalize our method as an extension of two-level -calculus, and prove it correct. Furthermore, we show that our type-directed partial evaluator can be derived from a simple online syntax-directed partial evaluator with higher-order abstract syntax, by the same transformatio...

### Citations

605 |
The Definition of Standard ML (Revised
- Milner, Tofte, et al.
- 1997
(Show Context)
Citation Context ...t Always Work Reflection is difficult: Although the above method works for the pure simply-typed -calculus, it doesn't straightforwardly apply to practical programming languages such as Scheme and ML =-=[10]-=-, because it is impossible 2 to coerce a symbol into an arbitrary type. For example, how can we coerce a symbol into an integer? The more powerful a type system becomes, the more difficult (if not imp... |

302 |
Higher-order abstract syntax
- Pfenning, Elliot
- 1988
(Show Context)
Citation Context ...Background In this subsection, we briefly explain basic ideas of the cogen-based approach to online syntax-directed partial evaluation. 3.1.1 Higher-order Abstract Syntax Higher-order abstract syntax =-=[12]-=- is a meta-programming technique that represents binding at the object level by binding at the meta level to make environment manipulation simple and efficient. For example, let us represent untyped -... |

220 | Revised5 report on the algorithmic language Scheme
- Kelsey, Clinger, et al.
- 1998
(Show Context)
Citation Context ...s α → α. Since the type tells us that p @ s is a function, we expand it to λv. p @ s @ v, which reduces to λv. v. Here, v is a fresh symbol and λ is the syntax constructor of λ-abstraction. In Scheme =-=[8]-=-, this procedure can be illustrated as below. Generation of the fresh symbol is omitted for brevity. ∗A reformatted version of the article that appeared in Computer Software, vol. 17, no. 3, pp. 38–62... |

207 | Type-directed partial evaluation
- Danvy
(Show Context)
Citation Context ...normal form of p @ s. Traditional syntax-directed partial evaluation performs the normalization by symbolically manipulating the abstract syntax tree of a term, while type-directed partial evaluation =-=[4]-=- does it by expanding the term to a two-level term according to the type, and reducing the expanded two-level term statically and weakly. The expansion is called reification. In the above example, p @... |

156 |
Revised report on the algorithmic language Scheme
- Clinger, Rees
- 1991
(Show Context)
Citation Context ...d as ff ! ff. Since the type tells us that p @ s is a function, we expand it to v: p @ s @ v, which reduces to v: v. Here, v is a fresh symbol andsis the syntax constructor of -abstraction. In Scheme =-=[8]-=-, this procedure can be illustrated as below. Generation of the fresh symbol is omitted for brevity. 3 A reformatted version of the article that appeared in Computer Software, vol. 17, no. 3, pp. 38--... |

130 | Representing monads - Filinski - 1994 |

91 | Shortcut to Deforestation in Calculational Form - Takano, Meijer - 1995 |

42 | Encoding types in ML-Like languages
- Yang
(Show Context)
Citation Context ...those annotations automatically by ordinary type inference. For example, let us partially evaluate x: (y: y) @ 0 x in ML. We represent a type as a reification operator for values of the type, as Yang =-=[18]-=- did. For example, we represent a type variable as an untagging function for dynamic expressions (T). It is undefined for static values, because we never need to reify a static value whose type is unk... |

27 | Cogen in six lines
- Thiemann
- 1996
(Show Context)
Citation Context ... types of the values to reify, it also seems like a syntax-directed partial evaluator embedded in the source language. Actually, it corresponds to an online version of Thiemann's cogen-based approach =-=[16, 17]-=- to syntax-directed partial evaluators with higher-order abstract syntax. This observation is significant for the following two reasons. ffl It clarifies why type-directed partial evaluation is faster... |

20 |
Combinators for program generation
- Thiemann
- 1999
(Show Context)
Citation Context ... types of the values to reify, it also seems like a syntax-directed partial evaluator embedded in the source language. Actually, it corresponds to an online version of Thiemann's cogen-based approach =-=[16, 17]-=- to syntax-directed partial evaluators with higher-order abstract syntax. This observation is significant for the following two reasons. ffl It clarifies why type-directed partial evaluation is faster... |

14 | Sound specialization in the presence of computational effects
- Lawall, Thiemann
- 1997
(Show Context)
Citation Context ... the execution stage (not at the specialization stage) can be managed by let insertion [3]. Duplication, elimination, and reordering of code and computation can also be avoided by a similar technique =-=[9]-=-. It is our future work to treat more complicated side effects such as set-car! in Scheme. 5.3 Arithmetic Reduction It is straightforward to perform arithmetic reduction by primitive operators such as... |

12 |
An Inverse of the Evaluation Functional for Typed lambda-calculus
- Berger, Schwichtenberg
- 1991
(Show Context)
Citation Context ...ch unnecessary reflection and lengthy result occur when the type doesn't exactly express how the function actually behaves. Formally, type-directed partial evaluation produces a long fi-j-normal form =-=[2]-=-, which may contain j-redices. Such inexactness is inevitable in type systems with complete type inference (e.g. the Hindley-Milner type system). For the purpose of avoiding this problem, Sheard [14] ... |

12 | on-line partial evaluator for a polymorphic language
- Sheard
- 1997
(Show Context)
Citation Context ...e more powerful a type system becomes, the more difficult (if not impossible) the reflection becomes. For instance, reflection over disjoint sum types and inductive types is impossible or complicated =-=[4, 14]-=-. An extreme case is dynamic typing. In dynamically-typed languages such as Scheme, the domain of a function is essentially undecidable at the specialization stage, so reflection is impossible. Reflec... |

6 | A study in higher-order programming languages
- Rhiger
- 1997
(Show Context)
Citation Context ...a waste of the memory (for storing the intermediate data structure) and the time (for traversing it by pattern matching). We can remove the overhead by composing the constructors with the destructors =-=[13, 15]-=-. fun rHAbs f = HAbs(fn x =? f x) fun rHApp(t1, t2) = let val t1' = t1 val t2' = t2 in (case t1' of HAbs f =? f t2' ---s=? HApp(t1', t2')) end We can simplify these composed constructors by j-reductio... |

5 |
Partial evaluation of call-by-value -calculus with side-effects
- Asai, Masuhara, et al.
- 1997
(Show Context)
Citation Context ...effects (including type errors and non-termination) in detail, though we may incorporate existent techniques that find critical computations by program analysis and residualize them by let insertion (=-=[1]-=-, for example). 1.7 Overview The rest of this article is structured as follows. Section 2 formally presents the object language and our partial evaluator. Section 3 explains the derivation of our type... |

5 | Pragmatic aspects of type-directed partial evaluation
- Danvy
- 1996
(Show Context)
Citation Context ... which is probable in the Hindley-Milner type system. power A power function for integers, with the exponent (= 10) static. append An append function for lists of integers, with the first argument (= =-=[2; 3; 5]-=-) static. SK A combination of S/K-combinators that computes 2 2 3 in Church numbers. This is an example where a lot of polymorphic function application occurs at the specialization stage. format A str... |

4 |
Partial evaluation of callby-value λ-calculus with side-effects
- Asai, Masuhara, et al.
- 1997
(Show Context)
Citation Context ...effects (including type errors and non-termination) in detail, though we may incorporate existent techniques that find critical computations by program analysis and residualize them by let insertion (=-=[1]-=-, for example). 1.7 Overview The rest of this article is structured as follows. Section 2 formally presents the object language and our partial evaluator. Section 3 explains the derivation of our type... |

3 | Two flavors of offline partial evaluation
- Helsen, Thiemann
- 1998
(Show Context)
Citation Context ... untyped -calculus. However, it won't work as a partial evaluator for realistic languages with various values, because it relies on the property that all values are functions. ffl Helsen and Thiemann =-=[7]-=- compared Danvy's type-directed partial evaluator and the second author's cogenbased offline syntax-directed partial evaluator [16, 17], and found them similar both qualitatively and quantitatively. W... |

1 |
Online type-directed partial evaluation. Technical Report RS-97-53, Basic Research in Computer Science
- Danvy
- 1997
(Show Context)
Citation Context ... don't perform reflection at all. Instead, we conservatively extend primitive value destructors, so that they correctly handle residual code. A similar idea has already been proposed in previous work =-=[5, 14]-=-, but its application was rather limited, probably because reflection was still used. We exploit the idea much more extensively, and completely unnecessitate reflection. For example, we extend functio... |

1 |
Godelisation in the untyped -calculus
- Mogensen
- 1999
(Show Context)
Citation Context ...uation and a cogen-based approach to syntax-directed partial evaluation with higher-order abstract syntax, which enables incorporation of both techniques. Our method is not so useful for Godelization =-=[11]-=- as it is for partial evaluation, because it requires extension of destructors (e.g. from @ to @ 0 ) or preprocessing of the source program (to replace, e.g., @ with @ 0 ). Furthermore, this article d... |

1 |
Gödelisation in the untyped λ-calculus
- Mogensen
- 1999
(Show Context)
Citation Context ...uation and a cogen-based approach to syntax-directed partial evaluation with higher-order abstract syntax, which enables incorporation of both techniques. Our method is not so useful for Gödelization =-=[11]-=- as it is for partial evaluation, because it requires extension of destructors (e.g. from @ to @ ′ ) or preprocessing of the source program (to replace, e.g., @ with @ ′ ). Furthermore, this article d... |