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
4 - Assignment and Side Effects
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
In the previous chapters, with their spiraling build-up of repetition and variations, you may have felt like you were being subjected to the Lisp-equivalent of Ravel's Bolero. Even so, no doubt you noticed two motifs were missing: assignment and side effects. Some languages abhor both because of their nasty characteristics, but since Lisp dialects procure them, we really have to study them here. This chapter examines assignment in detail, along with other side effects that can be perpetrated. During these discussions, we'll necessarily digress to other topics, notably, equality and the semantics of quotations.
Coming from conventional algorithmic languages, assignment makes it more or less possible to modify the value associated with a variable. It induces a modification of the state of the program that must record, in one way or another, that such and such a variable has a value other than its preceding one. For those who have a taste for imperative languages, the meaning we could attribute to assignment seems simple enough. Nevertheless, this chapter will show that the presence of closures as well as the heritage of λ-calculus complicates the ideas of binding and variables.
The major problem in defining assignment (and side effects, too) is choosing a formalism independent of the traits that we want to define. As a consequence, neither assignment nor side effects can appear in the definition.
- Type
- Chapter
- Information
- Lisp in Small Pieces , pp. 111 - 146Publisher: Cambridge University PressPrint publication year: 1996