Guile’s binary and textual port interface was heavily inspired by R6RS, so many R6RS port interfaces are documented elsewhere. Note that R6RS ports are not disjoint from Guile’s native ports, so Guile-specific procedures will work on ports created using the R6RS API, and vice versa. Also note that in Guile, all ports are both textual and binary. See Input and Output, for more on Guile’s core port API. The R6RS ports module wraps Guile’s I/O routines in a helper that will translate native Guile exceptions to R6RS conditions; See R6RS I/O Conditions, for more. See R6RS File Ports, for documentation on the R6RS file port interface.
Note: The implementation of this R6RS API is not complete yet.
See Binary I/O, for documentation.
Return the end-of-file (EOF) object.
(eof-object? (eof-object)) ⇒ #t
See Ports, for documentation.
Return a transcoder associated with the encoding of port. See Encoding, and See R6RS Transcoders.
#t, as all ports in Guile are suitable for binary and
textual I/O. See Encoding, for more details.
returns a new textual port with the specified transcoder.
Otherwise the new textual port’s state is largely the same as
that of binary-port.
If binary-port is an input port, the new textual
port will be an input port and
will transcode the bytes that have not yet been read from
If binary-port is an output port, the new textual
port will be an output port and
will transcode output characters into bytes that are
written to the byte sink represented by binary-port.
As a side effect, however,
closes binary-port in
a special way that allows the new textual port to continue to
use the byte source or sink represented by binary-port,
even though binary-port itself is closed and cannot
be used by the input and output operations described in this
(seek port SEEK_CUR 0). See Random Access.
#t is port supports
(seek port SEEK_SET offset).
See Random Access.
#t is port supports
Call proc, passing it port and closing port upon exit of proc. Return the return values of proc.
(eof-object? (lookahead-u8 input-port)).
Returns a fresh binary input port connected to standard input, or a
binary output port connected to the standard output or standard error,
respectively. Whether the port supports the
set-port-position! operations is implementation-dependent.
See Default Ports.
See Bytevector Ports.
See Custom Ports.
See Binary I/O.
See Textual I/O.
Reads an external representation from textual-input-port and returns the
datum it represents. The
get-datum procedure returns the next
datum that can be parsed from the given textual-input-port, updating
textual-input-port to point exactly past the end of the external
representation of the object.
Any interlexeme space (comment or whitespace, see Scheme Syntax) in the input is first skipped. If an end of file occurs after the interlexeme space, the end-of-file object is returned.
If a character inconsistent with an external representation is
encountered in the input, an exception with condition types
&i/o-read is raised. Also, if the end of
file is encountered after the beginning of an external representation,
but the external representation is incomplete and therefore cannot be
parsed, an exception with condition types
&i/o-read is raised.
datum should be a datum value. The
writes an external representation of datum to
textual-output-port. The specific external representation is
implementation-dependent. However, whenever possible, an implementation
should produce a representation for which
get-datum, when reading
the representation, will return an object equal (in the sense of
equal?) to datum.
Note: Not all datums may allow producing an external representation for which
get-datumwill produce an object that is equal to the original. Specifically, NaNs contained in datum may make this impossible.
put-datumprocedure merely writes the external representation, but no trailing delimiter. If
put-datumis used to write several subsequent external representations to an output port, care should be taken to delimit them properly so they can be read back in by subsequent calls to
See Buffering, for documentation on