2.23 Flattening Syntactic Sequences: nest
The bindings documented in this section are provided by the scheme/nest and scheme libraries, but not scheme/base.
(nest ([datum ] ) body ) |
Combines nested expressions that syntactically drift to the right into a more linear textual format, much in the same way that let* linearizes a sequence of nested let expressions.
For example,
[y 6])] |
[with-handlers ([exn:fail? (lambda (x) 15)])] |
[let-values ([(d r) (quotient/remainder x y)])]) |
is equivalent to
(let ([x 10] |
[y 6]) |
(with-handlers ([exn:fail? (lambda (x) 15)]) |
(let-values ([(d r) (quotient/remainder x y)]) |
The nest form is unusual in that it has no semantics apart from its expansion, and its implementation is easier to understand than a precise prose description:
(syntax-rules () |
[(nest () body0 body ) |
(let () body0 body )] |
[(nest ([form forms ]) body0 body ) |
(form forms (let () body0 body ))] |
[(nest ([form forms ] . more) body0 body ) |
(form forms (nest more body0 body ))])) |