► |  | How to Design Programs Languages

1 | Beginning Student
2 | Beginning Student with List Abbreviations
3 | Intermediate Student
4 | Intermediate Student with Lambda
5 | Advanced Student
| Index

▼ | 3 | Intermediate Student

3.1 | define
3.2 | define-struct
3.3 | local
3.4 | letrec, let, and let*
3.5 | Function Calls
3.6 | time
3.7 | Identifiers
3.8 | Primitive Operations
3.9 | Unchanged Forms

On this page:

local

top← prev up next →

#### 3.3`` local

(local [definition ...] expr)

Groups related definitions for use in expr. Each definition is evaluated in order, and finally the body expr is evaluated. Only the expressions within the local form (including the right-hand-sides of the definitions and the expr) may refer to the names defined by the definitions. If a name defined in the local form is the same as a top-level binding, the inner one “shadows” the outer one. That is, inside the local form, any references to that name refer to the inner one.

Since local is an expression and may occur anywhere an expression may occur, it introduces the notion of lexical scope. Expressions within the local may “escape” the scope of the local, but these expressions may still refer to the bindings established by the local.

top← prev up next →