1 Language Model
2 Syntactic Forms
3 Datatypes
4 Structures
5 Classes and Objects
6 Units
7 Contracts
8 Pattern Matching
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
Bibliography
Index
On this page:
expand
expand-syntax
expand-once
expand-syntax-once
expand-to-top-form
expand-syntax-to-top-form
11.8.1 Information on Expanded Modules
Version: 4.0.2

 

11.8 Expanding Top-Level Forms

(expand top-level-form)  syntax?

  top-level-form : any/c

Expands all non-primitive syntax in top-level-form, and returns a syntax object for the expanded form that contains only core forms, matching the grammar specified by Fully Expanded Programs.

Before top-level-form is expanded, its lexical context is enriched with namespace-syntax-introduce, just as for eval. Use syntax->datum to convert the returned syntax object into a printable datum.

(expand-syntax stx)  syntax?

  stx : syntax?

Like (expand stx), except that the argument must be a syntax object, and its lexical context is not enriched before expansion.

(expand-once top-level-form)  syntax?

  top-level-form : any/c

Partially expands form-level-form and returns a syntax object for the partially-expanded expression. Due to limitations in the expansion mechanism, some context information may be lost. In particular, calling expand-once on the result may produce a result that is different from expansion via expand.

Before top-level-form is expanded, its lexical context is enriched with namespace-syntax-introduce, as for eval.

(expand-syntax-once stx)  syntax?

  stx : syntax?

Like (expand-once stx), except that the argument must be a syntax object, and its lexical context is not enriched before expansion.

(expand-to-top-form top-level-form)  syntax?

  top-level-form : any/c

Partially expands top-level-form to reveal the outermost syntactic form. This partial expansion is mainly useful for detecting top-level uses of begin. Unlike the result of expand-once, expanding the result of expand-to-top-form with expand produces the same result as using expand on the original syntax.

Before stx-or-sexpr is expanded, its lexical context is enriched with namespace-syntax-introduce, as for eval.

(expand-syntax-to-top-form stx)  syntax?

  stx : syntax?

Like (expand-to-top-form stx), except that the argument must be a syntax object, and its lexical context is not enriched before expansion.

11.8.1 Information on Expanded Modules

Information for an expanded module declaration is stored in a set of syntax properties (see Syntax Object Properties) attached to the syntax object: