Next: , Previous: , Up: baselib   [Index]


4.3 Bodies

The ?body of a lambda, let, let*, let-values, let*-values, letrec, or letrec* expression, or that of a definition with a body consists of zero or more definitions followed by one or more expressions:

?definition?expression1 ?expression2

Each identifier defined by a ?definition is local to the ?body; that is, the identifier is bound, and the region of the binding is the entire ?body.

Example:

(let ((x 5))
  (define foo (lambda (y) (bar x y)))
  (define bar (lambda (a b) (+ (* a b) a)))
  (foo (+ x 3)))
⇒  45

When begin, let-syntax, or letrec-syntax forms occur in a 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 macro use.

An expanded ?body containing variable definitions can always be converted into an equivalent letrec* expression. For example, the let expression in the above example is equivalent to

(let ((x 5))
  (letrec* ((foo (lambda (y) (bar x y)))
            (bar (lambda (a b) (+ (* a b) a))))
    (foo (+ x 3))))