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.
These procedures are new to the reworked I/O in R6RS.