[Rd] sink(con, type = "message"): what is the reason why 'message' sinks cannot be stacked?
Henrik Bengtsson
henrik.bengtsson at gmail.com
Tue Mar 20 22:27:58 CET 2018
In ?sink we can read:
"Sink-ing the messages stream should be done only with great care.
For that stream file must be an already open connection, and there is
no stack of connections."
and:
"Do not sink the messages stream unless you understand the source
code implementing it and hence the pitfalls."
Does anyone know the background/reason for this? Is it a design
decision, or is it just that it was complicated/is not-yet
implemented? If the latter, I could add it to my to-do list looking
into how stacked message sinks could be supported.
Because of the limitation of only active "message" sink, it is more or
less impossible to reliably capture stderr in package code, or at
least not unconditionally, e.g.
if (sink.number("message") - 2L == 0) {
sink(con, type = "message")
...
} else {
# Do something else not relying on 'message' sinks
}
Any code/package that does not acknowledge the above, will hijack any
existing message sink.
/Henrik
More information about the R-devel
mailing list