William D Clinger scripsit:
> I concur. I would, however, warn the editors against
> the parallel overspecification that would come of
> requiring port-transcoder to return #f when passed
> a port created by open-string-{input,output}-port
> or make-custom-textual-{input,output,input/output}-port.
> The specification of port-transcoder needs to be changed
> in recognition of the fact that textual ports may or may
> not have transcoders.
+1
> > I suggest at least the minimal change of saying that the
> > procedures with-{input,output}-from file, open-{input,output}-file,
> > {read,peek,write}-char, read, write, newline and display be specified
> > to use the transcoder returned by native-transcoder.
I misspoke on this one: it's only the with-*-from-file
and open-*-file procedures that are relevant here; naturally the
others would use the transcoder (if any) that belongs to the port
being accessed.
> I would recommend against that, because implementations
> may have esoteric knowledge that lets them pick different
> transcoders based on the file's type or content.
An excellent point.
> That would be consistent with John's suggestion only if the
> native-transcoder were nonstandard (e.g. 'we-pick-em),
Which really won't work, because a transcoder is a tripartite
data structure (codec, eol-style, and error-handling).
> but requiring native-transcoder to return nonstandard
> values in implementations of unusually high quality
> seems like a mistake.
Quite so.
I withdraw this part of my comment, therefore, and instead propose
that the procedures with-{input,output}-from-port be added to the
port I/O library. These accept a port and a thunk and execute the
thunk, ensuring that the port is closed afterwards, in the manner of
with-{input,output}-from-file. With-*-from-file would then just be a
simple variant of these. Writing a portable version of with-*-from-port
would not be easy, particularly in the presence of various threading
models, so it should be provided by the implementation.
> The simple procedures are supposed to be simple; if a
> programmer needs to supply an optional transcoder,
> I think the programmer should open the file using the
> io ports library instead.
With-*-from-port makes the combination straightforward: open
with the port I/O library, but do transput with the simple I/O
library.
--
Andrew Watt on Microsoft: John Cowan
Never in the field of human computing cowan at ccil.org
has so much been paid by so many http://www.ccil.org/~cowan
to so few! (pace Winston Churchill)
Received on Sun Jun 10 2007 - 19:04:26 UTC