[Rd] Possible changes to connections

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Wed, 30 May 2007 18:06:43 +0100 (BST)


When I originally implemented connections in R 1.2.0, I followed the model in the 'Green Book' closely. There were a number of features that forced a particular implementation, and one was getConnection() that allows one to recreate a connection object from a number.

I am wondering if anyone makes use of this, and if so for what?

It would seem closer to the R philosophy to have connection objects that get garbage collected when no R object refers to them. This would allow for example

readLines(gzfile("foo.gz"))

which currently leaks a connection slot as the connection cannot be closed (except via closeAllConnections() or getConnection()) without an R object being returned.

The correct usage currently is

readLines(con <- gzfile("foo.gz")); close(con)

which is a little awkward but more importantly seems little understood.

Another issue is that the current connection objects can be saved and restored but refer to a global table that is session-specific so they lose their meaning (and perhaps gain an unintended one).

What I suspect is that very few users are aware of the Green Book description and so we have freedom to make some substantial changes to the implementation. Both issues suggest that connection objects should be based on external pointers (which did not exist way back in 1.2.0).

[I know there is a call to getConnection in package gtools, but the return value is unused!]

-- 
Brian D. Ripley,                  ripley_at_stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Wed 30 May 2007 - 17:08:28 GMT

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 31 May 2007 - 17:33:46 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.