manpagez: man pages & more
info guile
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.14.10.2 Port Manipulation

The procedures listed below operate on any kind of R6RS I/O port.

Scheme Procedure: port-position port

If port supports it (see below), return the offset (an integer) indicating where the next octet will be read from/written to in port. If port does not support this operation, an error condition is raised.

This is similar to Guile’s seek procedure with the SEEK_CUR argument (see section Random Access).

Scheme Procedure: port-has-port-position? port

Return #t is port supports port-position.

Scheme Procedure: set-port-position! port offset

If port supports it (see below), set the position where the next octet will be read from/written to port to offset (an integer). If port does not support this operation, an error condition is raised.

This is similar to Guile’s seek procedure with the SEEK_SET argument (see section Random Access).

Scheme Procedure: port-has-set-port-position!? port

Return #t is port supports set-port-position!.

Scheme Procedure: call-with-port port proc

Call proc, passing it port and closing port upon exit of proc. Return the return values of proc.

Scheme Procedure: binary-port? port

Return #t if port is a binary port, suitable for binary data input/output.

Note that internally Guile does not differentiate between binary and textual ports, unlike the R6RS. Thus, this procedure returns true when port does not have an associated encoding—i.e., when (port-encoding port) is #f (see section port-encoding). This is the case for ports returned by R6RS procedures such as open-bytevector-input-port and make-custom-binary-output-port.

However, Guile currently does not prevent use of textual I/O procedures such as display or read-char with binary ports. Doing so “upgrades” the port from binary to textual, under the ISO-8859-1 encoding. Likewise, Guile does not prevent use of set-port-encoding! on a binary port, which also turns it into a “textual” port.

Scheme Procedure: textual-port? port

Always return #t, as all ports can be used for textual I/O in Guile.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]
© manpagez.com 2000-2026
Individual documents may contain additional copyright information.