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

From: John Cowan <cowan>
Date: Sat Feb 10 12:25:44 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
Received on Sat Feb 10 2007 - 12:25:37 UTC

This archive was generated by hypermail 2.3.0 : Wed Oct 23 2024 - 09:15:01 UTC