The predicate
tcl_string(Term, TclString)can be used to explicitly convert any Prolog term to a corresponding Tcl string:
In this case, more data processing is performed and so more data types can be converted to Tcl, in particular bignums and rationals.[eclipse 18]: tcl_string([a, b, c], X). X = " {a b c}" yes.
This predicate is mainly used to pass Prolog lists to Tcl commands with tcl/2 , e.g.[eclipse 20]: tcl_string([2_3, ["a b c", 2347236456534, []], 3.15e+14], S). S = " {0.666666687 {{a b c} 2.34723633e+12 {}} 3.15e+14}" yes.
The main use of this predicate consists of passing Prolog lists to Tcl commands with tcl/2 .[eclipse 8]: tcl_string([a, b, c], L), tcl('foreach w ## {toplevel .$w}', [L]). L = " {a b c}" yes.