put-char(3scm) Scheme Programmer's Manual put-char(3scm)

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

(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

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

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).

Returns unspecified values.

(define (write-with-sign n)
  (write-char (if (negative? n) #\- #\+))
  (write (abs n)))
(write-with-sign 10)
        ==> "+10"
(write-with-sign -12)
        ==> "-12"

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.

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

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.
&i/o-encoding (R6RS)
The port's transcoder is in raise mode and it encountered a character that could not be translated into bytes. The untranslated character can be retrieved from the condition.
&i/o-write (R6RS)
There was an I/O error during the write operation.
&i/o-port (R6RS)
If this is included as part of an I/O condition then the port related to the I/O error can be retrieved with i/o-error-port(3scm).
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.

display(3scm), fputc(3)

R4RS, IEEE Scheme, R5RS, R6RS, R7RS

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.

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/.

IEEE Scheme accidentally omitted write-char.
2022-03-29