> On Jul 10, 2019, at 1:53 PM, bruno cuconato <bccl...@gmail.com> wrote: > > there's > https://docs.racket-lang.org/reference/port-lib.html#%28def._%28%28lib._racket%2Fport..rkt%29._with-output-to-string%29%29 > > <https://docs.racket-lang.org/reference/port-lib.html#%28def._%28%28lib._racket%2Fport..rkt%29._with-output-to-string%29%29> > and company. > would that work for you? > > -- bruno cuconato
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 -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/5D3552E4-F7E0-4223-8D99-A16C40E30FFE%40gmail.com. For more options, visit https://groups.google.com/d/optout.