[flexi-streams-devel] byte-transformer for in-memory streams

Chris Dean ctdean at sokitomi.com
Sun Jan 7 06:34:18 UTC 2007


I have a need in my code to use in-memory streams that read and write
from strings using read-byte and write-byte.  I could convert back and
forth using octets-to-string and string-to-octets.  For example:

  (octets-to-string (with-output-to-sequence (out) 
                      (write-byte 65 out)))
  => "A"

But I wish to avoid the garbage created by this conversion process.

I propose an addition to flexi-streams that allows in-memory streams
to use a function to transform each byte as it is written and read
from a sequence.  For example:

  (with-output-to-sequence (out :element-type 'base-char 
                                :byte-transformer #'code-char) 
    (write-byte 65 out))
  => "A"

with-input-from-sequence has a similar change.

A patch is attached.   Comments and request for changes welcome. 

I use flexi-streams all the time.  A great package!  Thanks for all
your hard work on it.

Cheers,
Chris Dean


-------------- next part --------------
A non-text attachment was scrubbed...
Name: flexi-stream-transformer.patch
Type: text/x-patch
Size: 8156 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/flexi-streams-devel/attachments/20070106/56ffcd82/attachment.bin>


More information about the Flexi-streams-devel mailing list