[ Term Manipulation | Reference Manual | Alphabetic Index ]

term_string(?Term, ?String, +Options)

Configurable conversion between a Prolog term and a string.
Prolog term.
String or a variable.
List of read or write options


If String is instantiated, its contents are parsed (using read_term/3 and the given Options).

If String is not instantiated, Term is written into a string (using write_term/3 with options corresponding to writeq/2, followed and possibly overridden by the given Options).

Inapplicable options are silently ignored.

Modes and Determinism


This predicate is sensitive to its module context (tool predicate, see @/2).


(4) instantiation fault
Options is insufficiently instantiated.
(5) type error
String is instantiated, but not to a string.
(5) type error
Options is not a list or does not only contain compound terms.
(6) out of range
Options is a list containing compound terms that are not valid options.
(7) string contains unexpected characters
String cannot be converted to a Prolog term.


    ?- term_string([1,a], S, [dotlists(true)])
    S = ".(1,.(a,[]))"

    ?- term_string(['A',3+4], S, [quoted(false),operators(false)])
    S = "['A',+(3,4)]"

    ?- term_string(T, "[1,Y,_]", [variable_names(V)]).
    T = [1, Y, _208]
    V = ['Y' = Y]

See Also

term_string / 2, number_string / 2, read_term / 3, write_term / 3, sprintf / 3