Book contents
- Frontmatter
- Contents
- To the Reader
- 1 The Basics of Interpretation
- 2 Lisp, 1, 2, … ω
- 3 Escape & Return: Continuations
- 4 Assignment and Side Effects
- 5 Denotational Semantics
- 6 Fast Interpretation
- 7 Compilation
- 8 Evaluation & Reflection
- 9 Macros: Their Use & Abuse
- 10 Compiling into C
- 11 Essence of an Object System
- Answers to Exercises
- Bibliography
- Index
10 - Compiling into C
Published online by Cambridge University Press: 05 June 2012
- Frontmatter
- Contents
- To the Reader
- 1 The Basics of Interpretation
- 2 Lisp, 1, 2, … ω
- 3 Escape & Return: Continuations
- 4 Assignment and Side Effects
- 5 Denotational Semantics
- 6 Fast Interpretation
- 7 Compilation
- 8 Evaluation & Reflection
- 9 Macros: Their Use & Abuse
- 10 Compiling into C
- 11 Essence of an Object System
- Answers to Exercises
- Bibliography
- Index
Summary
Once again, here's a chapter about compilation, but this time, we'll look at new techniques, notably, flat environments, and we have a new target language: C. This chapter takes up a few of the problems of this odd couple. This strange marriage has certain advantages, like free optimizations of the compilation at a very low level or freely and widely available libraries of immense size. However, there are some thorns among the roses, such as the fact that we can no longer guarantee tail recursion, and we have a hard time with garbage collection.
Compiling into a high-level language like C is interesting in more ways than one. Since the target language is so rich, we can hope for a translation that is closer to the original than would be some shapeless, linear salmagundi. Since C is available on practically any machine, the code we produce has a good chance of being portable. Moreover, any optimizations that such a compiler can achieve are automatically and implicitly available to us. This fact is particularly important in the case of C, where there are compilers that carry out a great many optimizations with respect to allocating registers, laying out code, or choosing modes of address—all things that we could ignore when we focused on only one source language.
On the other hand, choosing a high-level language as the target imposes certain philosophic and pragmatic constraints as well.
- Type
- Chapter
- Information
- Lisp in Small Pieces , pp. 359 - 416Publisher: Cambridge University PressPrint publication year: 1996