[Larceny-users] Ports' type changes unexpectedly

William D Clinger will at ccs.neu.edu
Thu Mar 19 09:21:23 EDT 2009


Derick Eddington wrote:
> Closing string input ports or string output ports changes them from
> textual to binary and they are no longer considered input or output
> ports.  Ikarus, PLT, and Ypsilon don't do this.  I'm not sure what R6RS
> requires about this,

The R6RS library 8.2.6 specification of close-port says
a closed port is still a port, but does not say a closed
input port is still an input port, nor does it say a
closed output port is still an output port.  In fact,
it says the opposite, albeit not as explicitly as it
should have.

The R6RS library 8.2.6 specification of transcoded-port
says the closed binary port "cannot be used by the input
and output operations described in this chapter."  The
specifications of those operations, e.g. port-eof? and
flush-output-port, say they accept an input-port or an
output-port as their argument.  If a closed port were
still an input-port or an output-port, then a closed
port would be acceptable as an input to one of those
procedures.

Since the R6RS library document says a closed port is
not acceptable to the port-eof? and flush-output-port
procedures, a closed port cannot be an input port or an
output port.

That means the behavior of Ikarus, PLT, and Ypsilon is
not consistent with R6RS library chapter 8.

> but this is unexpected and could cause serious confusion.

The R6RS mandates many behaviors that are unexpected and
could cause serious confusion.  In this case, however,
Larceny's R6RS-conforming behavior is consistent with
long-standing practice in R5 Scheme, and is less
confusing than having input ports for which port-eof?
would raise an exception or having output ports for which
flush-output-port would raise an exception.  The confusion,
it would seem, comes from the violation of R6RS semantics
by Ikarus, PLT, and Ypsilon.

The fact that Larceny's binary-port? predicate returns
true for a closed port is a bug, which we will fix.  As
explained above, the R6RS library document requires
binary-port? to return false when its argument is a
closed port.

Will



More information about the Larceny-users mailing list