Previous Contents Next
7.15 Input/output from/to constant terms
These built-in predicates enable a Prolog term to be input from or output to a Prolog constant term (atom, character list or character code list). All these predicates can be defined using constant term streams (section 7.11). They are however simpler to use.

7.15.1 read_term_from_atom/3, read_from_atom/2, read_token_from_atom/2
[default]read_term_from_atom/3@read_term_from_atom/3|textbf7.15.1htoc [default]read_from_atom/2@read_from_atom/2|textbf7.15.1htoc [default]read_token_from_atom/2@read_token_from_atom/2|textbf7.15.1htoc
Templates

read_term_from_atom(+atom ?term, +read_option_list)
read_from_atom(+atom, ?term)
read_token_from_atom(+atom, ?nonvar)
Description

Like read_term/3[default]read_term/3@read_term/37.15.1htoc, read/2[default]read/2@read/27.15.1htoc (section 7.14.1) and read_token/2[default]read_token/2@read_token/27.15.1htoc (section 7.14.3) except that characters are not read from a text-stream but from Atom; the atom given as first argument.

Errors

Atom is a variable    instantiation_error
Atom is neither a variable nor an atom    type_error(atom, Atom)
see associated predicate errors    (section 7.14.1) and (section 7.14.3)

Portability

GNU Prolog predicates.

7.15.2 read_term_from_chars/3, read_from_chars/2, read_token_from_chars/2
[default]read_term_from_chars/3@read_term_from_chars/3|textbf7.15.2htoc [default]read_from_chars/2@read_from_chars/2|textbf7.15.2htoc [default]read_token_from_chars/2@read_token_from_chars/2|textbf7.15.2htoc
Templates

read_term_from_chars(+character_list ?term, +read_option_list)
read_from_chars(+character_list, ?term)
read_token_from_chars(+character_list, ?nonvar)
Description

Like read_term/3[default]read_term/3@read_term/37.15.2htoc, read/2[default]read/2@read/27.15.2htoc (section 7.14.1) and read_token/2[default]read_token/2@read_token/27.15.2htoc (section 7.14.3) except that characters are not read from a text-stream but from Chars; the character list given as first argument.

Errors

Chars is a partial list or a list with an element E which is a variable    instantiation_error
Chars is neither a partial list nor a list    type_error(list, Chars)
an element E of the Chars list is neither a variable nor a character    type_error(character, E)
see associated predicate errors    (section 7.14.1) and (section 7.14.3)

Portability

GNU Prolog predicates.

7.15.3 read_term_from_codes/3, read_from_codes/2, read_token_from_codes/2
[default]read_term_from_codes/3@read_term_from_codes/3|textbf7.15.3htoc [default]read_from_codes/2@read_from_codes/2|textbf7.15.3htoc [default]read_token_from_codes/2@read_token_from_codes/2|textbf7.15.3htoc
Templates

read_term_from_codes(+character_code_list ?term, +read_option_list)
read_from_codes(+character_code_list, ?term)
read_token_from_codes(+character_code_list, ?nonvar)
Description

Like read_term/3[default]read_term/3@read_term/37.15.3htoc, read/2[default]read/2@read/27.15.3htoc (section 7.14.1) and read_token/2[default]read_token/2@read_token/27.15.3htoc (section 7.14.3) except that characters are not read from a text-stream but from Codes; the character code list given as first argument.

Errors

Codes is a partial list or a list with an element E which is a variable    instantiation_error
Codes is neither a partial list nor a list    type_error(list, Codes)
an element E of the Codes list is neither a variable nor an integer    type_error(integer, E)
an element E of the Codes list is an integer but not a character code    representation_error(character_code, E)
see associated predicate errors    (section 7.14.1) and (section 7.14.3)

Portability

GNU Prolog predicates.

7.15.4 write_term_to_atom/3, write_to_atom/2, writeq_to_atom/2,
write_canonical_to_atom/2, display_to_atom/2, print_to_atom/2,
format_to_atom/3
[default]write_term_to_atom/3@write_term_to_atom/3|textbf7.15.4htoc [default]write_to_atom/2@write_to_atom/2|textbf7.15.4htoc [default]writeq_to_atom/2@writeq_to_atom/2|textbf7.15.4htoc [default]write_canonical_to_atom/2@write_canonical_to_atom/2|textbf7.15.4htoc [default]display_to_atom/2@display_to_atom/2|textbf7.15.4htoc [default]print_to_atom/2@print_to_atom/2|textbf7.15.4htoc [default]format_to_atom/3@format_to_atom/3|textbf7.15.4htoc
Templates

write_term_to_atom(?atom, ?term, +write_option_list)
write_to_atom(?atom, ?term)
writeq_to_atom(?atom, ?term)
write_canonical_to_atom(?atom, ?term)
display_to_atom(?atom, ?term)
print_to_atom(?atom, ?term)
format_to_atom(?atom, +character_code_list_or_atom, +list)
Description

Similar to write_term/3[default]write_term/3@write_term/37.15.4htoc, write/2[default]write/2@write/27.15.4htoc, writeq/2[default]writeq/2@writeq/27.15.4htoc, write_canonical/2[default]write_canonical/2@write_canonical/27.15.4htoc, display/2[default]display/2@display/27.15.4htoc, print/2[default]print/2@print/27.15.4htoc (section 7.14.6) and format/3[default]format/3@format/37.15.4htoc (section 7.14.7) except that characters are not written onto a text-stream but are collected as an atom which is then unified with the first argument Atom.

Errors

Atom is neither a variable nor an atom    type_error(atom, Atom)
see associated predicate errors    (section 7.14.6) and (section 7.14.7)

Portability

GNU Prolog predicates.

7.15.5 write_term_to_chars/3, write_to_chars/2, writeq_to_chars/2,
write_canonical_to_chars/2, display_to_chars/2, print_to_chars/2,
format_to_chars/3
[default]write_term_to_chars/3@write_term_to_chars/3|textbf7.15.5htoc [default]write_to_chars/2@write_to_chars/2|textbf7.15.5htoc [default]writeq_to_chars/2@writeq_to_chars/2|textbf7.15.5htoc [default]write_canonical_to_chars/2@write_canonical_to_chars/2|textbf7.15.5htoc [default]display_to_chars/2@display_to_chars/2|textbf7.15.5htoc [default]print_to_chars/2@print_to_chars/2|textbf7.15.5htoc [default]format_to_chars/3@format_to_chars/3|textbf7.15.5htoc
Templates

write_term_to_chars(?character_list, ?term, +write_option_list)
write_to_chars(?character_list, ?term)
writeq_to_chars(?character_list, ?term)
write_canonical_to_chars(?character_list, ?term)
display_to_chars(?character_list, ?term)
print_to_chars(?character_list, ?term)
format_to_chars(?character_list, +character_code_list_or_atom, +list)
Description

Similar to write_term/3[default]write_term/3@write_term/37.15.5htoc, write/2[default]write/2@write/27.15.5htoc, writeq/2[default]writeq/2@writeq/27.15.5htoc, write_canonical/2[default]write_canonical/2@write_canonical/27.15.5htoc, display/2[default]display/2@display/27.15.5htoc, print/2[default]print/2@print/27.15.5htoc (section 7.14.6) and format/3[default]format/3@format/37.15.5htoc (section 7.14.7) except that characters are not written onto a text-stream but are collected as a character list which is then unified with the first argument Chars.

Errors

Chars is neither a partial list nor a list    type_error(list, Chars)
see associated predicate errors    (section 7.14.6) and (section 7.14.7)

Portability

GNU Prolog predicates.

7.15.6 write_term_to_codes/3, write_to_codes/2, writeq_to_codes/2,
write_canonical_to_codes/2, display_to_codes/2, print_to_codes/2,
format_to_codes/3
[default]write_term_to_codes/3@write_term_to_codes/3|textbf7.15.6htoc [default]write_to_codes/2@write_to_codes/2|textbf7.15.6htoc [default]writeq_to_codes/2@writeq_to_codes/2|textbf7.15.6htoc [default]write_canonical_to_codes/2@write_canonical_to_codes/2|textbf7.15.6htoc [default]display_to_codes/2@display_to_codes/2|textbf7.15.6htoc [default]print_to_codes/2@print_to_codes/2|textbf7.15.6htoc [default]format_to_codes/3@format_to_codes/3|textbf7.15.6htoc
Templates

write_term_to_codes(?character_code_list, ?term, +write_option_list)
write_to_codes(?character_code_list, ?term)
writeq_to_codes(?character_code_list, ?term)
write_canonical_to_codes(?character_code_list, ?term)
display_to_codes(?character_code_list, ?term)
print_to_codes(?character_code_list, ?term)
format_to_codes(?character_code_list, +character_code_list_or_atom, +list)
Description

Similar to write_term/3[default]write_term/3@write_term/37.15.6htoc, write/2[default]write/2@write/27.15.6htoc, writeq/2[default]writeq/2@writeq/27.15.6htoc, write_canonical/2[default]write_canonical/2@write_canonical/27.15.6htoc, display/2[default]display/2@display/27.15.6htoc, print/2[default]print/2@print/27.15.6htoc (section 7.14.6) and format/3[default]format/3@format/37.15.6htoc (section 7.14.7) except that characters are not written onto a text-stream but are collected as a character code list which is then unified with the first argument Codes.

Errors

Codes is neither a partial list nor a list    type_error(list, Codes)
see associated predicate errors    (section 7.14.6) and (section 7.14.7)

Portability

GNU Prolog predicates.


Copyright (C) 1999-2001 Daniel Diaz

Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.

More about the copyright
Previous Contents Next