a version of source() which keeps comments ?

Friedrich.Leisch@ci.tuwien.ac.at Friedrich.Leisch@ci.tuwien.ac.at
Thu, 20 Jun 2002 12:21:11 +0200

>>>>> On Thu, 20 Jun 2002 12:13:33 +0200,
>>>>> Martin Maechler (MM) wrote:

  > I'd like to have this to be used in, e.g.,
  > demo() and example().

  > Currently, source() parse()s the entire file and then evaluates
  > expression by expression. ``Of course'',  parse() already loses
  > the comments.

  > An (much slower) alternative might be to the readLine() the
  > file, echo what we read, 
  > and try to parse() ``the current chunk''.
  > when parse() fails (when the current expression is incomplete),
  > we silently read the next line, etc, until the expression is complete and hence
  > parse() succeeds, then we eval() and print().

  > What do people think?

  > Would there be volunteers to write this?
  > [I think it should finalize as an optional argument to source(), 
  >  but for experimentation it might be easier to try with a
  >  function  sourceLinewise(.)
  > ].

I'm not a volunteer but the feature would also be extremely useful for
Sweave (and probably most other dynamic report approaches), where we
currently loose all comments in code chunks.

r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch