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
9 - Macros: Their Use & Abuse
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
Inored, abused, unjustly criticized, insufficiently justified (theoretically), macros are no less than one of the fundamental bases of Lisp and have contributed significantly to the longevity of the language itself. While functions abstract computations and objects abstract data, macros abstract the structure of programs. This chapter presents macros and explores the problems they pose. By far one of the least studied topics in Lisp, there is enormous variation in macros in the implementation of Lisp or Scheme. Though this chapter contains few programs, it tries to sweep through the domain where these little known beings—macros—have evolved.
Invented by Timothy P. Hart [SG93] in 1963 shortly after the publication of the Lisp 1.5 reference manual, macros turned out to be one of the essential ingredients of Lisp. Macros authorize programmers to imagine and implement the language appropriate to their own problem. Like mathematics, where we continually invent new abbreviations appropriate for expressing new concepts, dialects of Lisp extend the language by means of new syntactic constructions. Don't get me wrong: I'm not talking about augmenting the language by means of a library of functions covering a particular domain. A Lisp with a library of graphic functions for drawing is still Lisp and no more than Lisp. The kind of extensions I'm talking about introduce new syntactic forms that actually increase the programmer's power.
Extending a language means introducing new notation that announces that we can write X when we want to signify Y.
- Type
- Chapter
- Information
- Lisp in Small Pieces , pp. 311 - 358Publisher: Cambridge University PressPrint publication year: 1996