[r6rs-discuss] Proposed features for small Scheme, part 2: I/O
Peter Bex
Peter.Bex at xs4all.nl
Sat Sep 5 07:04:38 EDT 2009
On Fri, Sep 04, 2009 at 10:04:37PM -0400, John Cowan wrote:
> I'm a little reluctant to say that codecs are entirely unnecessary, since
> system defaults may well not suffice, although only the ASCII (trivial)
> codec should be required. There are just too many files lying about
> systems these days with non-standard encodings. If codecs are restored,
> I propose this interface:
>
> [something like R6RS io ports] port-codec, set-port-codec!
>
> If no codec is set and textual I/O is done, the system default applies.
Codecs sound too much like special-casing to me. If custom ports are
supported in Thing One, couldn't "codecs" be handled simply by a
procedure accepting a port and returning a new port which applies the
codec to the original port?
I've done something similar in the "intarweb" egg for Chicken Scheme,
which uses user-defined ports to convert a port into a chunked HTTP/1.1
content-encoding port. Why not do the same to convert line endings?
If all ports are inherently binary, a textual port could be obtained by
wrapping calling, say, a (->utf8-port my-port) converter around it.
Newlines could be similarly handled where needed. This way, one can
arbitrarily mix encoding converters with newline converters.
Cheers,
Peter
--
http://sjamaan.ath.cx
--
"The process of preparing programs for a digital computer
is especially attractive, not only because it can be economically
and scientifically rewarding, but also because it can be an aesthetic
experience much like composing poetry or music."
-- Donald Knuth
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 478 bytes
Desc: not available
Url : http://lists.r6rs.org/pipermail/r6rs-discuss/attachments/20090905/e498dca5/attachment.pgp
More information about the r6rs-discuss
mailing list