I’m using with-out-str to capture some data that is printed to stdout. Problem is that with-out-str seems to throw away the return value from my function. Is there any way I can capture both? I’d like to have my cake and eat it too.
Example:
(with-out-str (do (prn "test") (+ 1 1)))
Aping the definition of the core library’s
with-out-strmacro, you could define a similar one like this:Without the
valuesfunction from Common Lisp and its multiple function return values, here we return a vector instead; the first item is the text collected from standard output, and the second item is the value returned by evaluating the body form.