Page 1 of 1

Where is an input-output stream

Posted: Wed Apr 11, 2012 10:17 am
by Jasper
I mean a stream you can write to, and when you read from it, the same comes out. Basically as in the example make-two-way-stream, but with less angering me by showing it can be done but only giving an horribly crappy way.

Basically i want a function that makes `(make-two-way-stream (make-string-input-stream "") (make-string-output-stream))` that makes an object so that `(close that-object)` ...closes it.

Re: Where is an input-output stream

Posted: Wed Apr 11, 2012 2:03 pm
by gugamilare
So, what you want is a virtual file?

I think the only way to do that would be to use Gray Streams or Simple Streams. I did it a while ago using the compatibility library Flexi-Streams using in-memory streams, but it ended not working quite the way I expected it to.

I hope you have more luck with it than I did :)

Re: Where is an input-output stream

Posted: Wed Apr 11, 2012 4:06 pm
by nuntius
Unfortunately, CL only has a limited set of stream types built in. The file stream and string stream are the basic types. The broadcast-, concatenated-, echo-, synonym-, and two-way-stream types allow for chaining and composition.

If you want to use the stream API, and your pattern doesn't fit in the standard classes, then you probably want to use Gray streams.

Flexi-streams adds a layer on top of Gray streams that you probably don't need based on your current description.