Module byte [Preloaded]

Bytes can be written to binary streams or read from binary streams. Binary streams can be obtained by the to open/3 and open/4 system predicates documented in the stream control section. The standard output and/or the standard input might also point to binary streams, but this is not guaranteed.

Text streams and binary streams share the notion of flushing and end of stream. Therefore the system predicates flush_output/[0,1] and at_end_of_stream/[0,1] apply to both text streams and binary streams.

The following byte input/output predicates are provided:

put_byte(B): [ISO 8.13.3]
put_byte(H, B): [ISO 8.13.3]
The unary predicate writes the byte B to the standard output. The binary predicate takes an additional binary stream sink as argument.
get_byte(B): [ISO 8.13.1]
get_byte(H, B): [ISO 8.13.1]
The predicate reads a byte from the standard input. The predicate succeeds when B unifies with the read byte or the integer -1 when the end of the stream has been reached.The binary predicate takes an additional binary stream source as argument.
peek_byte(B): [ISO 8.13.2]
peek_byte(H, B): [ISO 8.13.2]
The predicate reads a byte from the standard input and puts it back. The predicate succeeds when B unifies with the read byte or the integer -1 when the end of the stream has been reached. The binary predicate takes an additional binary stream source as argument.
flush_output: [ISO 8.11.7]
flush_output(S): [ISO 8.11.7]
The predicate without arguments flushes the standard output. The unary predicate takes an additional text or binary stream sink as argument.
at_end_of_stream: [ISO 8.11.8]
at_end_of_stream(S): [ISO 8.11.8]
The predicate without arguments checks whether we are at the end of the standard input. The unary predicate takes an additional text or binary stream sink as argument.
read_block(L, B):
read_block(I, L, B):
The predicate succeeds in a block B in reading maximally L bytes from I.
write_block(B):
write_block(O, B):
The predicate succeeds in writing the byte block B to O.

Kommentare