instead of using print(), use str(). Also, be even more cautious
about cleaning up in printToString; previously, errors in printing
would lead to a sink to a closed fifo...
Printing is still not really right, and I forsee that we will end up
writing our own printer to get something more lispy. But at least
this approach tends not to dump huge tables into the REPL.
printToString <- function(val) {
f <- fifo("")
- tryCatch({ sink(f); print(val); sink(); readLines(f) },
+ sink(f)
+ tryCatch({
+ tryCatch(str(val, indent.str="", list.len=5, max.level=2),
+ finally=sink())
+ readLines(f) },
finally=close(f))
}