3.23 Blocks: block (original) (raw)
top contents [← prev](%5F%5Ftop-interaction.html "backward to "3.22 Interaction Wrapper: #%top-interaction"") [up](syntax.html "up to "3 Syntactic Forms"") [next →](stratified-body.html "forward to "3.24 Internal-Definition Limiting: #%stratified-body"")
3.23 Blocks: block🔗ℹ
(require racket/block) | package: base |
---|
The bindings documented in this section are provided by the racket/block library, not racket/base or racket.
syntax
(block defn-or-expr ...)
Supports a mixture of expressions and mutually recursive definitions, as in a module body. Unlike an internal-definition context, the last defn-or-expr need not be an expression.
The result of the block form is the result of the last defn-or-expr if it is an expression,# otherwise. If no defn-or-expr is provided (after flattening begin forms), the result is #.
The final defn-or-expr is executed in tail position, if it is an expression.
Examples:
> (define (f x) (block (define y (add1 x)) (displayln y) (define z (* 2 y)) (+ 3 z))) > (f 12) 13 29
top contents [← prev](%5F%5Ftop-interaction.html "backward to "3.22 Interaction Wrapper: #%top-interaction"") [up](syntax.html "up to "3 Syntactic Forms"") [next →](stratified-body.html "forward to "3.24 Internal-Definition Limiting: #%stratified-body"")