From henrik.bengtsson at gmail.com  Tue Mar 20 22:27:58 2018
From: henrik.bengtsson at gmail.com (Henrik Bengtsson)
Date: Tue, 20 Mar 2018 14:27:58 -0700
Subject: [Rd] sink(con,
 type = "message"): what is the reason why 'message' sinks
 cannot be stacked?
Message-ID: <CAFDcVCSpYOihfdxy6cr5cX3_jXj8fKcCUqr2jcH-hwd5mNgf9A@mail.gmail.com>

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



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