On this page:
nest

31 scheme/nest

 (require scheme/nest) package: scheme-lib

syntax

(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,

(nest ([let ([x 10]
             [y 6])]
       [with-handlers ([exn:fail? (lambda (x) 15)])]
       [parameterize ([current-output-port (current-error-port)])]
       [let-values ([(d r) (quotient/remainder x y)])])
  (display (+ d r)))

is equivalent to

(let ([x 10]
      [y 6])
  (with-handlers ([exn:fail? (lambda (x) 15)])
    (parameterize ([current-output-port (current-error-port)])
      (let-values ([(d r) (quotient/remainder x y)])
        (display (+ d r))))))

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:

(define-syntax nest
  (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 ...))]))