term_str

term_str(PROLOG_term,STRING) -(i,o),(o,i)

This predicate converts prolog terms to strings, and vice-versa. It is implemented internally by calling the standard Visual Prolog predicate "term_str/3", except that the first argument of "term_str/3" is no longer necessary, since G.I.S. Prolog terms do not require type-definitions.

Note that the current implementation of term_str/2 uses the original "internal domains", within the (Visual Prolog-) implementation of G.I.S. Prolog. E.g. the Prolog term 'this(1,2,that)' will be converted to the (Visual Prolog-) string cmp("this",[int(1),int(2),atom("that")]), and not to the normal string-term "this(1,2,that)", and vice-versa.

term_str(this(1,2,that),X).

X= cmp("this",[int(1),int(2),atom("that")])

1 Solution

The predicate "term_str/2" can thus also provide (1) a degree of insight into the internal workings of G.I.S. Prolog, and (2) certain types of meta-programming possibilities. It is also possible to write or read terms in the internal Visual Prolog domain format, and convert them to ISO-Prolog terms, and vice-versa. This possibility is exploited in the implementation of the G.I.S. Prolog DCG grammar parser.