| put-string(3scm) | Scheme Programmer's Manual | put-string(3scm) |
NAME
put-string, write-string - write a string to a textual output port
LIBRARY
(import (rnrs)) ;R6RS (import (rnrs io ports)) ;R6RS (import (scheme base)) ;R7RS
SYNOPSIS
; R6RS only: (put-string textual-output-port string) (put-string textual-output-port string start) (put-string textual-output-port string start count) ; R7RS only: (write-string string) (write-string string textual-output-port) (write-string string textual-output-port start) (write-string string textual-output-port start end)
DESCRIPTION
Writes the characters of string starting at index start to textual-output-port.
- R6RS
- Exactly count characters are written, defaulting to (string-length string) − start.
- R7RS
- The characters from start to end are written, with end defaulting to (string-length string).
The start argument defaults to 0.
RETURN VALUES
EXAMPLES
(write-string "Hello, world!\n")
APPLICATION USAGE
This procedure is used, instead of a generic procedure like display(scheme), because it is slightly faster and makes it possible to write only part of the string.
RATIONALE
The R7RS variant specifies end instead of count to be consistent with other procedures.
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. In particular, start and count must be non-negative exact integer objects, and string must have a length of at least start + count.
- &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.
SEE ALSO
put-char(3scm), display(3scm), open-file-output-port(3scm)
STANDARDS
R6RS, R7RS
HISTORY
The put-string procedure was introduced in R6RS as part of the reworked I/O design. The write-string procedure is new in R7RS.
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/.
| 2022-05-23 |