Thanks! Yes, I think with a little tinkering I can get that to work for what I have in mind. Took me awhile to discover *how* that is supposed to work! Apparently the proc for with-output-to-string is a thunk:
(with-output-to-string (λ a
(printf "a=~a~%" a)
(define x 10)
(define y 20)
(printf "x=~a y=~a~%" x y)))
=> "a=()\nx=10 y=20\n”
Something a little macro can handle:
(define-syntax (output->string stx)
(syntax-parse stx
[(_ body:expr ...) #'(with-output-to-string (thunk body ...))]))
(output->string
(define x 10)
(define y 20)
(printf "x=~a y=~a~%" x y))
=> "x=10 y=20\n"
Kevin