> Is there a sensible way to write the contents of one stream 
> to another? 

No one has written a reply to this question! I expect this means that there is no nice way to do it. I plan to submit an RCR about this. What I essentially want is a mechanism for writing an input stream to an output stream, so I don't have to create a suitable buffer and read, write, read, write myself.

Which of the following options appeal more to you:

1) ostream << istream works differently for istream than for any other object. instead of writing to_s to the stream it writes the contents of the istream.

2) ostream.writeStream(istream) is added as a separate method.

3) ostream << anObject invokes anObject.writeToStream(ostream).

class Object
   def writeToStream(anOStream)
      anOStream << to_s
   end
end

class IO
   def writeToStream(anOStream)
      // override Object impl. and write this object to anOStream
   end
end


I like 3, except that if anIO2 in 'anIO1 << anIO2' is not open for input it doesn't make a lot of sense. More evidence to the point that IO is a little bit messy, I think.

What do you think?

Thomas


> I know
> 
> ostream.write(istream.read)
> 
> works, and it reads nice, but the entire contents of istream 
> is loaded into memory, and that is not always reasonable.
> 
> I think the least surprising thing would be for 
> 
> ostream.write(istream)
> 
> to write the contents of istream to ostream. The same goes 
> for ostream << istream.
> 
> Thomas
>