flush-output-port(3scm) Scheme Programmer's Manual flush-output-port(3scm)

flush-output-port - flush buffered data from a port to its sink

(import (rnrs))                     ;R6RS
(import (rnrs io ports))            ;R6RS
(import (scheme base))              ;R7RS

(flush-output-port output-port)

Flushes any buffered output from the buffer of output-port to the underlying file, device, or object.

Vicare Scheme
The standard output port is block buffered and it is not closed on exit. A manual flush is needed before exiting the program.

R6RS
Returns unspecified values.
R7RS
Returns an unspecified value.

(display "Enter your name: ")
(flush-output-port (current-output-port))
(define name (get-line (current-input-port)))

Used to manually flush a port's internal buffers. The port is automatically flushed when the port is closed, so there is no need for a manual flush before closing a port.

Output ports are line buffered, block buffered or unbuffered. Buffering is typically good for performance, but sometimes applications need to write data immediately.

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 an invalid byte sequence.
&i/o-write (R6RS)
There was an I/O error during the write operation.
&i/o-port (R6RS)
This condition specifies the port object related to the &i/o-write condition.
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.

call-with-port(3scm), close-port(3scm)

R6RS, R7RS

This procedure first appeared in R6RS as part of the reworked I/O system.

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

2023-07-24