Book contents
- Frontmatter
- Abstract
- Contents
- Preface
- 1 Partial Evaluation in Principle
- 2 Partial Evaluation in Practice
- 3 Static Projections
- 4 Binding-Time Analysis
- 5 Run Time Arguments
- 6 Implementation
- 7 Polymorphism
- 8 Conclusion
- A Implementation of PEL
- B Implementation of BTA
- C Implementation of Specialisation
- D Library Functions
- Bibliography
- Index
2 - Partial Evaluation in Practice
Published online by Cambridge University Press: 04 August 2010
- Frontmatter
- Abstract
- Contents
- Preface
- 1 Partial Evaluation in Principle
- 2 Partial Evaluation in Practice
- 3 Static Projections
- 4 Binding-Time Analysis
- 5 Run Time Arguments
- 6 Implementation
- 7 Polymorphism
- 8 Conclusion
- A Implementation of PEL
- B Implementation of BTA
- C Implementation of Specialisation
- D Library Functions
- Bibliography
- Index
Summary
Having seen some of the principles of partial evaluation we now consider practicalities. In this chapter we will study the standard algorithm used in partial evaluation and introduce an extended example which we develop throughout the thesis. The material of this chapter draws very heavily on the experience of the DIKU group and much of the material presented here may be found in [JSS85], [Ses86] and [JSS89].
Partial evaluation has been attempted in a number of different programming paradigms. The earliest work used LISP-like languages because programs in such languages can easily be treated as data. In particular, the first self-applicable partial evaluator was written in a purely functional subset of first-order, statically scoped LISP. Since then work has been done to incorporate other language features of LISP like languages including, for example, global variables [BD89]. A self-applicable partial evaluator for a term rewriting language has been achieved [Bon89], and more recently a higher-order A-calculus version has been developed [Gom89].
Because of these successes, partial evaluation is sometimes linked with functional languages. Indeed the word “evaluation” itself is expression orientated. However, partial evaluation has also become popular in logic languages, and in Prolog in particular. Kursawe, investigating “pure partial evaluation”, shows that the principles are the same in both the logic and functional paradigms [Kur88]. Using the referentially opaque clause primitive, very compact interpreters (and hence partial evaluators) can be written. However, it is not clear how the clause predicate itself should be handled by a partial evaluator and, hence, whether this approach can ever lead to self-application. Other “features” of Prolog that can cause problems for partial evaluation are the cut and negation-by-failure.
- Type
- Chapter
- Information
- Project Factorisations in Partial Evaluation , pp. 13 - 27Publisher: Cambridge University PressPrint publication year: 1991