Where is an input-output stream

Discussion of Common Lisp

Where is an input-output stream

Postby Jasper » Wed Apr 11, 2012 10:17 am

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.
Jasper
 
Posts: 209
Joined: Fri Oct 10, 2008 8:22 am
Location: Eindhoven, The Netherlands

Re: Where is an input-output stream

Postby gugamilare » Wed Apr 11, 2012 2:03 pm

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 :)
gugamilare
 
Posts: 406
Joined: Sat Mar 07, 2009 6:17 pm
Location: Brazil

Re: Where is an input-output stream

Postby nuntius » Wed Apr 11, 2012 4:06 pm

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.
User avatar
nuntius
 
Posts: 498
Joined: Sat Aug 09, 2008 10:44 am
Location: Burlington, MA


Return to Common Lisp

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest

cron