From ellis at stat.harvard.edu  Thu Dec 29 06:17:44 2005
From: ellis at stat.harvard.edu (Byron Ellis)
Date: Wed, 28 Dec 2005 21:17:44 -0800
Subject: [Rd] Enhancement request: anonymous connections
In-Reply-To: <m2ek3xcm32.fsf@fhcrc.org>
References: <m2mzimc9zj.fsf@fhcrc.org> <43B1EE08.4090003@stats.uwo.ca>
	<m2ek3xcm32.fsf@fhcrc.org>
Message-ID: <33A6B5DE-C44D-42F8-933C-7C707FB6FF31@stat.harvard.edu>

I think what you're suggesting is that connections should become  
first-class citizens in the R world by becoming a CONSXP, an  
EXTPTRSXP + Finalizer or whatever (which wouldn't bother me a bit,  
BTW). Then they'd play by the same rules as everything else, although  
you might want to have an explicit close as well as a close on  
finalize, that way you could close and then reopen if you keep a  
reference around (It also really annoys me that close NULLs the value  
of the symbol right now). It'd also be nice to *gasp* have an API for  
I/O from the C side of things as well.

If we wanted to be truly radical we'd just accept that graphics  
devices and event loops are just special cases of the connection and  
merge the whole thing, thus more-or-less reinventing CLIM. :-)

On Dec 28, 2005, at 6:50 AM, Seth Falcon wrote:

> On 27 Dec 2005, murdoch at stats.uwo.ca wrote:
>> This is a bug in load, isn't it?  load() opens the connection but
>> doesn't close it.
>
> Well, it may be that load needs a small fix, but that doesn't fix
> anonymous connections in general, IMO.
>
> The loop could easily have been:
>
> for (i in 1:50) {
>     print(load(url(testUrl, open="r")))
> }
>
> And it doesn't need to be related to url or load:
>
> cat("a line of text\n", file="another-example.txt")
> z <- NULL
> for (i in 1:50) {
>     z <- c(z, readLines(file("another-example.txt", open="r")))
> }
>
> Also, connections are "in use" even if they are closed:
>
> for (i in 1:50) {
>     if (isOpen(file("another-example.txt")))
>         stop("you will not get here")
> }
>
>
> --
> + seth
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

---
Byron Ellis (ellis at stat.harvard.edu)
"Oook" -- The Librarian



[Rd] Enhancement request: anonymous connections
Byron Ellis