1 Evaluation Model
2 Syntax Model
3 Core Syntactic Forms
4 Core Datatypes
5 Structures
6 Classes and Objects
7 Units
8 Contracts
9 Control Flow
10 Concurrency
11 Macros
12 Input and Output
13 Reflection and Security
14 Operating System
15 Memory Management
16 Running PLT Scheme
Index
On this page:
#%top

contents

 index

← prev  up  next →

 

3.3 Variable References and #%top

id

Refers to a module-level or local binding, when id is not bound as a transformer (see Expanding Top-Level Forms). At run-time, the reference evaluates to the value in the location associated with the binding.

When the expander encounters an id that is not bound by a module-level or local binding, it converts the expression to (#%top . id) giving #%top the lexical context of the id; typically, that context refers to #%top. See also Expansion Steps.

Examples:

  > (define x 10)

  > x

  10

  > (let ([x 5]) x)

  5

  > ((lambda (x) x) 2)

  2

(#%top . id)

Refers to a top-level definition that could bind id, even if id has a local binding in its context. Such references are disallowed anywhere within a module form. See also Expansion Steps for information on how the expander introduces #%top identifiers.

Examples:

  > (define x 12)

  > (let ([x 5]) (#%top . x))

  12

 

contents

 index

← prev  up  next →