[Rd] parse( connection) and source-keeping

From: <Mark.Bravington_at_csiro.au>
Date: Thu, 12 Jan 2012 07:54:12 +1100

In R <= 2.13.x, calling 'parse( con)' where 'con' is a connection, 'options( keep.source)' is TRUE, and default 'srcfile' would preserve the source. In R >= 2.14.1, it doesn't.

> tf <- tempfile()
> options( keep.source=TRUE)
> texto <- c( 'function() { # comment', '}')
> parse( text=texto)

expression(function() { # comment
> cat( texto, file=tf, sep='\n')
> parse( file=tf)

expression(function() { # comment
> parse( file( tf))

expression(function() {
> parse( textConnection( texto))

expression(function() {

and yes I didn't bother closing any connections.

My suspicion is that this change is unintentional, and it seems to me that the best option would be for 'connection' to work like 'text' does here, ie to attach a 'srcfilecopy' containing the contents.

I didn't submit a bug report because the documentation (which hasn't changed in this respect) actually doesn't say what 'parse' should do with 'connection' (as opposed to 'text' or 'file') argument when 'getOption( keep.source)' is TRUE and 'srcfile' is NULL. [BTW it's also unstated which argument takes precedence if a non-default 'srcfile' argument is specified.] So some additional explanation is needed there at a minimum, but also a decision as to what the best behaviour would be.


Mark Bravington
Marine Lab


R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed 11 Jan 2012 - 21:21:39 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 12 Jan 2012 - 03:40:08 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive