[previous] [up] [next]     [contents] [index]
Next: Case-Lambda Up: Binding Forms Previous: Fluid-Let

Syntax Expansion and Embedded Definitions

All binding forms are macro expanded into define-values, let-values, and letrec*-values expressions. MzScheme's letrec and letrec-values are always implemented by letrec* and letrec*-values. The set!-values form is expanded to let-values with set!. See section 13.4 for more information.

All define-values expressions that are inside only begin expressions are treated as top-level definitions. Immediate body define-value expressions in a unit expression are handled specially as described in section 7.1.1. Any other define-values expression is either an embedded definition or syntactically illegal.

Embedded definitions only appear at the beginning of a block of sequenced expressions (e.g., using the begin form or the implicit sequencing of lambda) where at least one non-definition expression follows a sequence of embedded definitions. Note that the first expression in a begin0 expression cannot be an embedded definition; for the purposes of embedded definitions, the second expression is the start of the block.

An embedded define-values expression is transformed along with the rest of the expressions following it into a letrec*-values expression: the variables originally bound by the define-values expressions become the binding variables of the new letrec*-values expression, and the expressions that followed the define-values expressions become the body of the new letrec*-values expression.

Multiple adjacent define-values statements are collected into a single letrec*-values transformation so that the definitions can be mutually-recursive, but the define-values expressions really must be adjacent: a define-values expressions following a non-define-values expression is not an embedded definition.

An embedded defintion cannot shadow a syntax form or macro name. Thus, an embedded cannot alter the decision of whether another expression is also an embedded definition in the same letrec*-values transformation.[footnote]

Embedded macro definitions (using define-macro) are desecribed in section 13.1.



PLT