Abstract
The program transformation principle called partial evaluation has interesting applications in compilation and compiler generation. Self-applicable partial evaluators may be used for transforming interpreters into corresponding compilers and even for the generation of compiler generators. This is useful because interpreters are significantly easier to write than compilers, but run much slower than compiled code. A major difficulty in writing compilers (and compiler generators) is the thinking in terms of distinct binding times: run time and compile time (and compiler generation time). The paper gives an introduction to partial evaluation and describes a fully automatic though experimental partial evaluator, called mix, able to generate stand-alone compilers as well as a compiler generator. Mix partially evaluates programs written in Mixwell, essentially a first-order subset of statically scoped pure Lisp. For compiler generation purposes it is necessary that the partial evaluator be self-applicable. Even though the potential utility of a self-applicable partial evaluator has been recognized since 1971, a 1984 version of mix appears to be the first successful implementation. The overall structure of mix and the basic ideas behind its way of working are sketched. Finally, some results of using a version of mix are reported.
Similar content being viewed by others
References
Aho, A. V., Sethi, R., and J. D. Ullman,Compilers: Principles, Techniques and Tools, Addison-Wesley, Reading, Massachusetts, 1986.
Beckman, L., Haraldsson, A., Oskarsson,:O., and Sandewall, E. A partial evaluator, and its use as a programming tool.Artificial Intelligence 7, 4 (1976), 319–357.
Bjørner, D., Ershov, A. P., and Jones, N. D. (Eds.).Partial Evaluation and Mixed Computation, Gl. Avernæs, Denmark, 1987. North-Holland, Amsterdam, 1988 (to appear).
Bondorf, A. Towards a self-applicable partial evaluator for term rewriting systems. In [3].
Bulyonkov, M. A. Polyvariant mixed computation for analyzer programs.Acta Informatica 21 (1984), 473–484.
Bulyonkov, M. A. A theoretical approach to polyvariant mixed computation. In [3].
Burstall, R. M., and Darlington, J. A transformational system for developing recursive programs.Journal of the ACM 24 (1977), 44–67.
Christiansen, H., and Jones, N. D. Control flow treatment in a simple semantics-directed compiler generator.Proc IFIP WG 2.2: Formal Description of Programming Concepts II (D. Bjørner, Ed.), North-Holland, Amsterdam, 1983, pp. 73–99.
Codish, M., and Shapiro, E. Compiling or-parallelism into and-parallelism. Proc. Third International Conference on Logic programming, London, United Kingdom, (E. Shapiro, Ed.),Lecture Notes in Computer Science, Vol. 225, Springer-Verlag, New York, 1986, pp. 283–297.
Consel, C. New insights into partial evaluation: the Schism experiment. ESOP'88, European Symp. on Programming, Nancy, France (H. Ganzinger, Ed.).Lecture Notes in Computer Science, Vol. 300, Springer-Verlag, New York, 1988, pp. 236–246.
Cousot, P., and Cousot, R. Abstract interpretation: a unified lattice model for static analysis of programs by construction or approximation of fixpoints. Proc. Fourth ACM Symp. Principles of Programming Languages, Los Angeles, California 1977, pp. 238–252.
Dybkjær, H. Parsers and partial evaluation: An experiment. DIKU student report No. 85-7-15, University of Copenhagen, Denmark, 1985.
Emanuelson, P., and Haraldsson, A. On compiling embedded languages in Lisp. Proc. 1980 Lisp Conference, Stanford, California, 1980, pp. 208–215.
Ershov, A. P. On the essence of compilation.Formal Description of Programming Concepts (E. J. Neuhold, Ed.). North-Holland, Amsterdam, 1978, pp. 391–420.
Ershov, A. P. Mixed computation: Potential applications and problems for study.Theoretical Computer Science 18 (1982), 41–67.
Fujita, H., and Furukawa, K. A self-applicable partial evaluator and its use in incremental compilation.New Generation Computing 6 (2, 3), (June 1988) (to appear).
Fuller, D. A., and Abramsky, S. Mixed computation of Prolog programs.New Generation Computing 6 (2, 3) (June 1988) (to appear).
Futamura, Y. Partial evaluation of computation process—an approach to a compiler-compiler.Systems, Computers, Controls 2 (5) (1971), 45–50.
Futamura, Y. Partial computation of programs. Proc. RIMS Symp. Software Science and Engineering (E. Goto et al., Eds.).Lecture Notes in Computer Science, Vol. 147, Springer-Verlag, 1983, pp. 1–35.
Gallagher, J. Transforming logic programs by specialising interpreters. ECAI-86, Proc. 7th European Conference on Artificial Intelligence, 1986, pp. 109–122.
Ganzinger, H., and Jones, N. D. (Eds.). Programs as Data Objects, Copenhagen, Denmark.Lecture Notes in Computer Science, Vol. 217. Springer-Verlag, New York, 1986.
Haraldsson, A. A partial evaluator, and its use for compiling iterative statements in Lisp. Proc. Fifth ACM Symp. Principles of Programming Languages, Tucson, Arizona, 1978, pp. 195–202.
Heering, J. Partial evaluation and ω-completeness of algebraic specifications.Theoretical Computer Science 43 (1986), 149–167.
Hoare, C. A. R., and Allison, D. Incomputability.Computing Surveys 4 (3) (1972), 169–178.
Jones, N. D. Automatic program specialization: A re-examination from basic principles. In [3].
Jones, N. D., Sestoft, P., and Søndergaard, H. An experiment in partial evaluation: The generation of a compiler generator. Rewriting Techniques and Applications, Dijon, France (J.-P. Jouannaud, Ed.).Lecture Notes in Computer Science, 202. Springer-Verlag, New York, 1985, pp. 124–140.
Jørring, U., and Scherlis, W. L. Compilers and staging transformations. Proc. Thirteenth ACM Symp. Principles of Programming Languages, St. Petersburg, Florida, 1986, pp. 86–96.
Kahn, K. M. A partial evaluator of Lisp programs written in Prolog. Proc. First Int. Logic Programming Conf., Marseille, France, 1982 (M. Van Caneghem, Ed.), pp. 19–25.
Kahn, K. M., and Carlsson, M. The compilation of Prolog programs without the use of a Prolog compiler. Proc. Int. Conf. Fifth Generation Computer Systems, Tokyo, Japan, 1984, pp. 348–355.
Kleene, S. C.Introduction to Metamathematics, Van Nostrand, New York, 1952.
Komorowski, H. J. A Specification of an Abstract Prolog Machine and its Application to Partial Evaluation.Linköping Studies in Science and Technology Dissertations Vol. 69. University of Linköping, Sweden, 1981.
Kugler, H.-J. (Ed.),Information Processing 86, Proc. IFIP 86 Conf. North-Holland, Amsterdam, 1986.
Lee, P., and Pleban, U. A realistic compiler generator based on high-level semantics. Proc. Fourteenth ACM Symp. Principles of Programming Languages, Munich, FRG, 1987, pp. 284–295.
Lloyd, J. W., and Shepherdson, J. C. Partial evaluation in logic programming, Technical Report CS-87-09, Department of Computer Science, University of Bristol, England, 1987.
Lombardi, L. A. Incremental computation.Advances in Computers Vol. 8, (F. L. Alt and M. Rubinoff, Ed.), Academic, New York, 1967, pp. 247–333.
Lombardi, L. A., and Raphael, B. Lisp as the language for an incremental computer. InThe Programming Language Lisp: Its Operation and Application (E. C. Berkeley and D. G. Bobrow, Eds.). MIT Press, Cambridge, Massachusetts, 1964, pp. 204–219.
Mogensen, T. The Application of Partial Evaluation to Ray-Tracing. Master's thesis, University of Copenhagen, Denmark, 1986.
Mogensen, T. Partially static structures in a self-applicable partial evaluator. In [3].
Mosses, P. D. SIS—Semantics Implementation System, Reference Manual and User Guide, DAIMI Report MD-30, University of Aarhus, Denmark, 1979.
Paulson, L. A semantics-directed compiler generator. Proc. Ninth ACM Symp. Principles of Programming Languages, Albuquerque, New Mexico, 1982, pp. 224–233.
Rogers, H.Theory of Recursive Functions and Effective Computability. McGraw-Hill, New York, 1967.
Romanenko, S. A compiler generator produced by a self-applicable specializer can have a surprisingly natural and understandable structure. In [3].
Safra, S., and Shapiro, E. Meta interpreters for real. In [32] pp. 271–278.
Sestoft, P. The structure of a self-applicable partial evaluator. In [21] pp. 236–256.
Sestoft, P. Automatic call unfolding in a partial evaluator. In [3].
Sestoft, P., and Søndergaard, H. A bibliography on partial evaluation.SIGPLAN Notices 23 (2) (February 1988), 19–27.
Sestoft, P., and Zamulin, A. V. Annotated bibliography on partial evaluation and mixed computation. In [3].
Takeuchi, A., and Furukawa, K. Partial evaluation of Prolog programs and its application to meta programming. In [32] pp. 415–420.
TsNIPIASS.Bazisnyi Refal i yego Realizatsiya na Vychislitelnykh Mashinakh. TsNIPIASS, Gosstroi SSSR, Moscow, 1977.
Turchin, V. F. A supercompiler system based on the language Refal.SIGPLAN Notices 14 (2) (1979), 46–54.
Turchin, V. F., Nirenberg, R. M., and Turchin, D. V. Experiments with a supercompiler. Proc. 1982 ACM Symp. Lisp and Functional Programming, Pittsburgh, Pennsylvania, 1982, pp. 47–55.
Venken, R. A Prolog meta-interpreter for partial evaluation and its application to source to source transformation and query-optimisation.Proc. ECAI-84, Pisa, Italy (T. O'Shea, Ed.), North-Holland, Amsterdam, 1984, pp. 91–100.
Vickers, T. Quokka: A translator generator using denotational semantics.Australian Computer Journal 18 (1) (1986), 9–17.
Wand, M. From interpreter to compiler: A representational derivation. In [21] pp. 306–324.
Warren, D. Implementing Prolog—Compiling Predicate Logic Programs, DAI Research Report 39-40, University of Edinburgh, Scotland, 1977.
Watt, D. A. Executable semantic descriptions.Software—Practice and Experience 16 (1) (1986), 13–43.
Author information
Authors and Affiliations
Rights and permissions
About this article
Cite this article
Jones, N.D., Sestoft, P. & Søndergaard, H. Mix: A self-applicable partial evaluator for experiments in compiler generation. Lisp and Symbolic Computation 2, 9–50 (1989). https://doi.org/10.1007/BF01806312
Issue Date:
DOI: https://doi.org/10.1007/BF01806312