Next: , Previous: , Up: R6RS I/O Ports   [Contents][Index]


6.15.10.3 Buffer Modes

Each port has an associated buffer mode. For an output port, the buffer mode defines when an output operation flushes the buffer associated with the output port. For an input port, the buffer mode defines how much data will be read to satisfy read operations. The possible buffer modes are the symbols none for no buffering, line for flushing upon line endings and reading up to line endings, or other implementation-dependent behavior, and block for arbitrary buffering. This section uses the parameter name buffer-mode for arguments that must be buffer-mode symbols.

If two ports are connected to the same mutable source, both ports are unbuffered, and reading a byte or character from that shared source via one of the two ports would change the bytes or characters seen via the other port, a lookahead operation on one port will render the peeked byte or character inaccessible via the other port, while a subsequent read operation on the peeked port will see the peeked byte or character even though the port is otherwise unbuffered.

In other words, the semantics of buffering is defined in terms of side effects on shared mutable sources, and a lookahead operation has the same side effect on the shared source as a read operation.

Scheme Syntax: buffer-mode buffer-mode-symbol

buffer-mode-symbol must be a symbol whose name is one of none, line, and block. The result is the corresponding symbol, and specifies the associated buffer mode.

Note: Only the name of buffer-mode-symbol is significant.

Scheme Procedure: buffer-mode? obj

Returns #t if the argument is a valid buffer-mode symbol, and returns #f otherwise.


Next: , Previous: , Up: R6RS I/O Ports   [Contents][Index]