put-char, write-char - write a character to a port

LIBRARY

(import (rnrs))                     ;R6RS
(import (rnrs io ports))            ;R6RS, put-char
(import (rnrs io simple))           ;R6RS, write-char
(import (scheme r5rs))              ;R7RS
(import (scheme base))              ;R7RS

SYNOPSIS

(put-char textual-output-port char) ;R6RS
(write-char char)
(write-char char textual-output-port)

DESCRIPTION

Writes the character char to the textual-output-port.

If textual-output-port is omitted, it defaults to the value returned by current-output-port(3scm).

RETURN VALUES

Returns unspecified values.

EXAMPLES

(define (write-with-sign n)
  (write-char (if (negative? n) #\- #\+))
  (write (abs n)))

(write-with-sign 10)
        ==> "+10"

(write-with-sign -12)
        ==> "-12"

RATIONALE

The put-char procedure is consistent with the reworked I/O system in R6RS. The procedure write-char was kept for the simplified I/O system.

COMPATIBILITY

The write-char procedure exists in all RnRS reports since R2RS.

ERRORS

This procedure can raise exceptions with the following condition types:
&assertion (R6RS)
The wrong number of arguments was passed or an argument was outside its domain.
R7RS
The assertions described above are errors. Implementations may signal an error, extend the procedure's domain of definition to include such arguments, or fail catastrophically.

SEE ALSO

display(3scm), fputc(3)

STANDARDS

R4RS, IEEE Scheme, R5RS, R6RS, R7RS

HISTORY

The procedure write-char appeared in R2RS. It has no direct predecessor in MacLisp, but does exist in Common Lisp. The procedure put-char first appeared 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://github.com/schemedoc/manpages/.

BUGS

IEEE Scheme accidentally omitted write-char.


Markup created by unroff 1.0sc,    March 04, 2023.