[r6rs-discuss] [Formal] Buffer mode should be specifiable on open-file-input-port

John Cowan cowan at ccil.org
Sat Feb 10 12:25:37 EST 2007


Michael Sperber scripsit:

> Is this possible in general?  Specifically, transcoding on input
> requires some buffering, at least for multi-byte encodings.  Or do you
> intend this to work only for binary ports?

It depends on the implementation.  If the decoder invokes a procedure
(or a coroutine) to get the next byte, then no state is required,
because there are no encodings which are not streamable: that is, the
arrival of a later byte never affects the interpretation of an earlier
byte, and one can always determine from the lead byte of a multibyte
character how many trailing bytes must be read.  Transcoding, unlike
more general kinds of parsing, has no need for lookahead or pushback:
this postulate is so fundamental that I think it never even occurs to
anyone designing an encoding to violate it.

That does however open another question: on a transcoded port, does
buffering refer to character buffering, byte buffering, or both?  I'd say
that it refers to byte buffering, and that character buffering SHOULD
be the same.

-- 
John Cowan    http://ccil.org/~cowan    cowan at ccil.org
Economists were put on this planet to make astrologers look good.
        --Leo McGarry



More information about the r6rs-discuss mailing list