Inlining and specialization appear in various forms throughout the
implementation of modern programming languages. From mere compiler
optimizations to sophisticated techniques in partial evaluation, they
are omnipresent, yet each application is treated differently. This
paper is an attempt at uncovering the relations between inlining (as
done in production compilers) and staged computation (as done in
partial evaluators) in the hope of bringing together the research
advances in both fields. Using a two-level lambda calculus as the
intermediate language, we show how to model inlining as a staged
computation while avoiding unnecessary code duplication. The new
framework allows us to define inlining annotations iformally and to
reason about their interactions with module code. In fact, we present
a cross-module inlining algorithm that inlines all functions marked
inlinable, even in the presence of ML-style parameterized modules.
- In Journal of Functional Programming,
13(3), pages 647-676, May 2003.