File "charsio"

This Prolog text provides reading and writing memory streams. The approach is to cooperate with the native garbage collection. The predicates open_input_atom_stream/2 and open_output_atom_stream/2 create memory streams, but there is no bureaucracy necessary to manually free them when they are not needed anymore.

As a convenience the predicate term_atom/[2,3] allows writing a Prolog term into a new atom. The binary predicate will use writeq/1, the ternary predicate will use write_term/2 and if quoting isn’t desired, one needs to opt-out. The predicate can also read Prolog terms from a given atom, whereas by default it will not require a terminating period.

The following compat predicates are provided:

open_input_atom_stream(A, S):
The built-in succeeds in S with a new input stream for the atom A.
open_output_atom_stream(S):
The built-in succeeds in S with a new output stream.
close_output_atom_stream(S, A):
The built-in succeeds in A with the content of the output stream S.
term_atom(T, A):
term_atom(T, A, O):
The build-in succeeds in writing the term T into a new atom A. The ternary predicate accepts write options O.