| standard-input-port(3scm) | Scheme Programmer's Manual | standard-input-port(3scm) |
NAME
standard-input-port, standard-output-port, standard-error-port - fresh standard I/O ports
LIBRARY
(import (rnrs)) ;R6RS (import (rnrs io ports)) ;R6RS
SYNOPSIS
(standard-input-port) (standard-output-port) (standard-error-port)
DESCRIPTION
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.
RETURN VALUES
Returns a single value; a fresh port.
EXAMPLES
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))))))))
APPLICATION USAGE
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.
RATIONALE
These procedures make it possible to do binary I/O on standard input, output and error.
COMPATIBILITY
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.
ERRORS
This procedure can raise exceptions with the following condition types:
- &assertion (R6RS)
- The wrong number of arguments was passed.
SEE ALSO
current-input-port(3scm), make-transcoder(3scm)
STANDARDS
R6RS
HISTORY
These procedures are new to the reworked I/O in R6RS.
AUTHORS
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/.
BUGS
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 |