▼ |  | Syntax: Meta-Programming Helpers

1 | Parsing and Specifying Syntax
2 | Syntax Object Helpers
3 | Datum Pattern Matching
4 | Module-Processing Helpers
5 | Macro Transformer Helpers
6 | Reader Helpers
7 | Parsing for Bodies
8 | Unsafe for Clause Transforms
9 | Source Locations
10 | Preserving Source Locations
11 | Non-Module Compilation And Expansion
12 | Trusting Standard Recertifying Transformers
13 | Attaching Documentation to Exports
| Index

On this page:

split-for-body

5.92
top ← prev up next →

### 7`` Parsing for Bodies

(require syntax/for-body) | package: base

The syntax/for-body module provides a helper function for for-like syntactic forms that wrap the body of the form while expanding to another for-like form, and the wrapper should apply only after the last #:break or #:final clause in the body.

> procedure (split-for-body stx body-stxes) → syntax?
> stx : syntax?
> body-stxes : syntax?

The body-stxes argument must have the form (pre-body ... post-body ...), and it is rewritten into ((pre-body ...) (post-body ...)) such that (post-body ...) is as large as possible without containing a #:break or #:final clause.

The stx argument is used only for reporting syntax errors.

Use split-for-body instead of assuming that the last form in a for-like form’s body can be wrapped separately. In particular, the last form might contain definitions that need to be spliced in the same definition context as earlier forms to create mutually-recursive definitions.

top ← prev up next →