[Rd] RFC: rawConnection (was "loop connections")

Duncan Murdoch murdoch at stats.uwo.ca
Thu Sep 1 12:32:19 CEST 2005


dhinds at sonic.net wrote:
> Duncan Murdoch <murdoch at stats.uwo.ca> wrote:
> 
> 
>>I would implement it differently from the way you did.  I'd call it
>>a rawConnection, taking a raw variable (or converting something else
>>using as.raw) as the input, and providing both text and binary
>>read/write modes (using the same conventions for text mode as a file
>>connection would).  It *should* support seek, at least in binary
>>mode.
> 
> 
> I was trying to reuse as much of the textConnection semantics and
> underlying code as possible...
> 
> Having a rawConnection() entry point is simple enough.  Seeking also
> seems straightforward.  I'm not so sure about using as.raw().  I
> wondered about that, but also thought that rather than coercing to
> raw, it might make more sense to cast atomic vector types to raw,
> byte-for-byte.

I'd prefer as.raw, so that we don't end up with two incompatible ways to 
convert other objects to raw objects.

> Can you given an example of where a text-mode raw connection would be
> a useful thing?

No, but someone else might.  Why unnecessarily let the source of the 
bytes determine the mode of the connection?  In the case of 
textConnection, there are natural line breaks, so a text mode connection 
makes sense.  A raw object can contain anything, so why wouldn't someone 
want to put text in it some day?

Duncan Murdoch



More information about the R-devel mailing list