Section "code"

Communication over text streams is mainly done via codes or atoms. We therefore provide the ISO core standard predicate put_code/2 to send a code point and the ISO core standard predicates get_code/2 and peek_code/2 to receive a code point. Currently the default is that the stream is UTF-8 coded and code points are then Unicode.

The following code predicates are provided:
nl: [ISO 8.12.3]
nl(S): [ISO 8.12.3]
The predicate succeeds. As a side effect, a newline is written. The unary predicate al-lows specifying an output stream S.
flush_output: [ISO 8.11.7]
flush_output(S): [ISO 8.11.7]
The predicate succeeds. As a side effect, the current output is flushed. The unary predicate allows specifying an output stream S.
put_code(C): [ISO 8.12.3]
put_code(S, C): [ISO 8.12.3]
The unary predicate writes the code C to the standard output. The binary predicate takes an additional output stream S as argument.
put_atom(S):
put_atom(S, A):
The built-in succeeds. As a side effect, it adds the atom A to the output stream. The binary predicate allows specifying an output stream S.
get_code(S, C): [ISO 8.12.1]
The built-in succeeds in C with the next Unicode point from the stream S. As a side-effect the input pointer of the stream S is advanced.
get_code(C): [ISO 8.12.1]
get_code(S, C): [ISO 8.12.1]
The predicate reads a code from the standard input. The predicate succeeds when C unifies with the read code or the integer -1 when the end of the stream has been reached. The binary predicate takes an additional input stream S as argument.
peek_code(C): [ISO 8.12.2]
peek_code(S, C): [ISO 8.12.2]
The predicate reads a code from the standard input and puts it back. The predicate suc-ceeds when C unifies with the read code or the integer -1 when the end of the stream has been reached. The binary predicate takes an additional input stream S as argument.
get_atom(A, O):
get_atom(S, A, O):
The built-in succeeds in A with the atom from the input stream up to the atom options O. The ternary predicate allows specifying an input stream S. The available atom options are:

stop(D): The stop code point D, default is newline 0‘\n.
compress(B): The compressed newline flag B, default is true.
max(M): The maximum number M of code points, default is zero 0.

Kommentare