2.8 Reuse of top-level bindings

Bindings resulting from the successful execution of a top-level goal are asserted in a database if they are not too large. These values may be reused in further top-level queries as $Var. If the same variable name is used in a subsequent query the system associates the variable with the latest binding. Example:

1 ?- maplist(plus(1), "hello", X).
X = [105,102,109,109,112].

2 ?- format('~s~n', [$X]).
ifmmp
true.

3 ?-
Figure 1 : Reusing top-level bindings

Note that variables may be set by executing =/2:

6 ?- X = statistics.
X = statistics.

7 ?- $X.
28.00 seconds cpu time for 183,128 inferences
4,016 atoms, 1,904 functors, 2,042 predicates, 52 modules
55,915 byte codes; 11,239 external references

                      Limit    Allocated       In use
Heap         :                                624,820 Bytes
Local  stack :    2,048,000        8,192          404 Bytes
Global stack :    4,096,000       16,384          968 Bytes
Trail  stack :    4,096,000        8,192          432 Bytes
true.