[plt-scheme] re-open a bytes/string port?

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Fri Jan 16 15:06:00 EST 2009

At Fri, 16 Jan 2009 10:40:52 -0800, YC wrote:
> On Fri, Jan 16, 2009 at 5:53 AM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> >
> > There's no way to re-open the port. If the port is still open, you can
> > rewind to the beginning by using the (badly named) `file-position'
> > function.
> >
> I think I can probably get around this issue by creating my own port struct
> to hold the bytes and the opened byte port for pass through.  Something
> like:
> (define-struct byte-port (bytes port) #:property prop:input-port 1)
> Are there any issues (cost, synchronization, etc) with using port structs
> this way that I need to think about?

No --- that should work well. There is an overhead in using the wrapped
port, but it's small compared to most any operation on the port.


Posted on the users mailing list.