In Julia, you typically do not redirect stdout and capture the results (once upon a time you did, but it was slow and gave other issues as well). Instead, all output functions (including print and show) are expected to take an optional first argument of type IO. You can capture the output from such a function into a string using sprint:
julia> function f(io::IO, a, b) print(io, a); print(io, b); end f (generic function with 1 method) julia> sprint(f,"foo","bar") "foobar" Alternatively, maybe all you need to catch is the output from print or show. Then you can just use string or repr, respectively. On Sunday, 9 November 2014 16:08:10 UTC+1, Tamas Papp wrote: > > Hi, > > I am looking for the Julia equivalent of the Common Lisp macro/idiom > WITH-OUTPUT-TO-STRING, eg > > (with-output-to-string (s) > (format s "foo") > (format s "bar")) ; => "foobar" > > I looked at the Text I/O section of the manual but didn't find anything > similar. > > If this does not exist, a few hints on how to accumulate strings in an > IOstream would point me in the right direction, I think I can write the > macro part. > > Best, > > Tamas >