Next: , Up: scheme programs   [Index]


3.8.1 Top–level program syntax

A top–level program is a delimited piece of text, typically a file, that has the following form:

?import-form ?top-level-body

An ?import-form has the following form:

(import ?import-spec …)

A ?top-level-body has the following form:

?top-level-body-form

A ?top-level body form is either a ?definition or an ?expression.

The ?import-form is identical to the import clause in libraries, and specifies a set of libraries to import. A ?top-level-body is like a ?library-body, except that definitions and expressions may occur in any order. Thus, the syntax specified by ?top-level-body-form refers to the result of macro expansion.

When uses of begin, let-syntax, or letrec-syntax from the (rnrs base (6)) library occur in a top–level body prior to the first expression, they are spliced into the body. Some or all of the body, including portions wrapped in begin, let-syntax, or letrec-syntax forms, may be specified by a syntactic abstraction.