sink(con, type = "message"): what is the reason why 'message' sinks cannot be stacked?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

sink(con, type = "message"): what is the reason why 'message' sinks cannot be stacked?

Henrik Bengtsson-5
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

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel