Re: [Rd] isOpen on closed connections

2007-11-15 Thread Mark.Bravington
; -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Roger D. Peng > Sent: Thursday, 15 November 2007 11:48 PM > To: Prof Brian Ripley > Cc: R-devel mailing list > Subject: Re: [Rd] isOpen on closed connections > > Upon further con

Re: [Rd] isOpen on closed connections

2007-11-15 Thread Roger D. Peng
Upon further consideration, I realized there is a philosophical element here---if a connection is closed and hence does not exist, is it open? The practical issue for me is that when you do something like close(con) the 'con' object is still lying around and is essentially undefined. For exam

Re: [Rd] isOpen on closed connections

2007-11-15 Thread Henrik Bengtsson
My solution the original post is to always set 'con <- NULL' after closing a connection, and then test for NULL. This is how I do to make sure to make sure that opened connections are closed and as soon as possible. foo <- function(...) { con <- file("foo.R", open="r"): on.exit({ if (!is.

Re: [Rd] isOpen on closed connections

2007-11-14 Thread Prof Brian Ripley
I think the confusion here is over close(): that closes *and destroys* a connection, so it no longer exists. isOpen applies to existing connections: you cannot close but not destroy them at R level, but C code can (and does). You will see it in use in the utils package. On Wed, 14 Nov 2007,

Re: [Rd] isOpen on closed connections

2007-11-14 Thread Seth Falcon
"Roger D. Peng" <[EMAIL PROTECTED]> writes: > As far as I can tell, 'isOpen' cannot return FALSE in the case when 'rw = > ""'. > If the connection has already been closed by 'close' or some other function, > then isOpen will produce an error. The problem is that when isOpen calls > 'getConnec

[Rd] isOpen on closed connections

2007-11-14 Thread Roger D. Peng
As far as I can tell, 'isOpen' cannot return FALSE in the case when 'rw = ""'. If the connection has already been closed by 'close' or some other function, then isOpen will produce an error. The problem is that when isOpen calls 'getConnection', the connection cannot be found and 'getConnection