Previous: , Up: Input and output   [Index]


6.13.3 Output

If port is omitted from any output procedure, it defaults to the value returned by (current-output-port). It is an error to attempt an output operation on a closed port.

write library procedure: write obj
write library procedure: write obj port

Writes a representation of obj to the given textual output port. Strings that appear in the written representation are enclosed in quotation marks, and within those strings backslash and quotation mark characters are escaped by backslashes. Symbols that contain non-ASCII characters are escaped with vertical lines. Character objects are written using the #\ notation.

If obj contains cycles which would cause an infinite loop using the normal written representation, then at least the objects that form part of the cycle must be represented using datum labels as described in Datum labels. Datum labels must not be used if there are no cycles.

Implementations may support extended syntax to represent record types or other types that do not have datum representations.

The write procedure returns an unspecified value.

write library procedure: write-shared obj
write library procedure: write-shared obj port

The write-shared procedure is the same as write, except that shared structure must be represented using datum labels for all pairs and vectors that appear more than once in the output.

write library procedure: write-simple obj
write library procedure: write-simple obj port

The write-simple procedure is the same as write, except that shared structure is never represented using datum labels. This can cause write-simple not to terminate if obj contains circular structure.

write library procedure: display obj
write library procedure: display obj port

Writes a representation of obj to the given textual output port. Strings that appear in the written representation are output as if by write-string instead of by write. Symbols are not escaped. Character objects appear in the representation as if written by write-char instead of by write.

The display representation of other objects is unspecified. However, display must not loop forever on self-referencing pairs, vectors, or records. Thus if the normal write representation is used, datum labels are needed to represent cycles as in write.

Implementations may support extended syntax to represent record types or other types that do not have datum representations.

The display procedure returns an unspecified value.

Rationale:

The write procedure is intended for producing machine-readable output and display for producing human-readable output.

procedure: newline
procedure: newline port

Writes an end of line to textual output port. Exactly how this is done differs from one operating system to another. Returns an unspecified value.

procedure: write-char char
procedure: write-char char port

Writes the character char (not an external representation of the character) to the given textual output port and returns an unspecified value.

procedure: write-string string
procedure: write-string string port
procedure: write-string string port start
procedure: write-string string port start end

Writes the characters of string from start to end in left-to-right order to the textual output port.

procedure: write-u8 byte
procedure: write-u8 byte port

Writes the byte to the given binary output port and returns an unspecified value.

procedure: write-bytevector bytevector
procedure: write-bytevector bytevector port
procedure: write-bytevector bytevector port start
procedure: write-bytevector bytevector port start end

Writes the bytes of bytevector from start to end in left-to-right order to the binary output port.

procedure: flush-output-port
procedure: flush-output-port port

Flushes any buffered output from the buffer of port to the underlying file or device and returns an unspecified value.


Previous: Input, Up: Input and output   [Index]