On 14 Sep 2009, at 7:21 pm, John Cowan wrote:
> Here are the 6 standard symbols for custom input ports and their
> default
> behaviors:
>
> read-char               Returns an eof-object
> peek-char               Returns an eof-object
> read-u8                 Returns an eof-object
> peek-u8                 Returns an eof-object
> port-u8-position        Does nothing
> set-port-u8-position!   Does nothing

How do you propose we deal with the issues of switching between char
and u8 operations? I've seen some offhand talk on IRC that once a char
operation has been used, a port is no good for binary any more, as the
encoding may be nontrivial and involve some look-ahead; can this not
be addressed by pushing bytes back into a buffer so a subsequent call
to read-u8 will return them without calling the underlying custom-port
read-u8? What is this evil encoding that makes it impossible to switch
back to binary mode after reading characters? One that uses Huffman
codes or something?

I ask because it's not uncommon to interleave binary and text in a
stream. Many binary formats have embedded strings, for example. Sure,
we could say "read it as binary and use some u8vector->string codec
functions", but then there's a jarring inconsistency; you can use a
port entirely for text with read-char, but if you want to read a
single binary byte from it, thereafter you need to read bytes and
decode them manually.



ABS

--
Alaric Snell-Pym
Work: http://www.snell-systems.co.uk/
Play: http://www.snell-pym.org.uk/alaric/
Blog: http://www.snell-pym.org.uk/archives/author/alaric/




_______________________________________________
r6rs-discuss mailing list
[email protected]
http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss

Reply via email to