1 Jun 2007 02:52
Re: [Rd] Possible changes to connections
Bill Dunlap <bill <at> insightful.com>
2007-06-01 00:52:51 GMT
2007-06-01 00:52:51 GMT
On Thu, 31 May 2007, Seth Falcon wrote: > > When I ran some tests I found 7 packages on CRAN that in their tests > > were not closing connections. Four of those are maintained by R-core > > members. > > Even though none were by me, I think this is too easy to forget to > > do! > > I agree that it is easy to forget. It is especially easy if one > creates so-called anonymous connection references like > readLines(file(path)) -- this anonymous idiom seems nature to me when > coding R and it would be nice to make it work for connections. I like the idea of the connection being closed when there are no more references to it. I guess that means when the garbage collector notices it has been orphaned, which may take a while. However, one of my longstanding complaints about connections in Splus and R may have a bearing here also. Currently, if you want to have your file opened in a particular way, say for only reading or for appending or in binary mode then you need to specify open=mode when calling file(). However that also tells it to actually open the file. I would prefer that there was a mode= argument to file that meant that when the file is eventually opened it would be opened with that mode. open= should be restricted to TRUE or FALSE, or IMO, be eliminated. (We have an open() function for that.) With the current system readLines(file(path)) does not leave path open but(Continue reading)
>
> However, one of my longstanding complaints about connections
> in Splus and R may have a bearing here also. Currently, if you
> want to have your file opened in a particular way, say for
> only reading or for appending or in binary mode then you
> need to specify open=mode when calling file(). However that
> also tells it to actually open the file. I would prefer that
> there was a mode= argument to file that meant that when the
RSS Feed