standard-input-port(3scm) Scheme Programmer's Manual standard-input-port(3scm)

standard-input-port, standard-output-port, standard-error-port - fresh standard I/O ports

(import (rnrs))                     ;R6RS
(import (rnrs io ports))            ;R6RS

(standard-input-port)
(standard-output-port)
(standard-error-port)

Returns a fresh binary port connected to standard input, standard output or standard error respectively. The first returns an input port and the latter two return output ports.

Whether the port supports the port-position(3scm) and set-port-position!(3scm) operations is implementation-dependent.

Returns a single value; a fresh port.

The following program converts its standard input from ISO-8859-1 to UTF-8 on its standard output.

(import (rnrs))
(call-with-port
    (transcoded-port (standard-input-port)
                     (make-transcoder (latin-1-codec)))
  (lambda (inp)
    (call-with-port
        (transcoded-port (standard-output-port)
                         (make-transcoder (utf-8-codec)))
      (lambda (outp)
        (let lp ()
          (let ((c (get-char inp)))
            (unless (eof-object? c)
              (put-char outp c)
              (lp))))))))

This is used in application that need binary I/O on the standard input, output and error. It can also be used to create transcoded ports for when the default transcoder on current-input-port(3scm) etc is not desired.

These procedures make it possible to do binary I/O on standard input, output and error.

These procedures are unique to R6RS. There is nothing similar in R7RS but some implementations will, as an extension, allow binary I/O on textual ports. Chibi-Scheme is an example of such an implementation.

This procedure can raise exceptions with the following condition types:
&assertion (R6RS)
The wrong number of arguments was passed.

current-input-port(3scm), make-transcoder(3scm)

R6RS

These procedures are new to the reworked I/O in R6RS.

This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at https://weinholt.se/scheme/manpages/.

Programs should use flush-output-port(3scm) or close-port(3scm) on these ports before exiting, or use call-with-port(3scm). The ports can be buffered and not all implementations flush open ports at exit.
2023-02-20