next up previous
Next: 13.2 Garbage-collectible permanent objects. Up: 13 The Blackboard Previous: 13 The Blackboard

13.1 Global logical variables

   Syntax: A#B:=:X, or lval(A,B,X).

where X is any term on the heap. It has simply a global name A#B i.e. an entry in the hashing table with keys A and B. The address in the table (C-pointers are the same as logical variables in BinProlog) is trailed such that on backtracking it will be unbound (i.e. point to itself). Unification with a logical global variable is possible at any point in the program which knows the `name' A#B.

Although a global logical variable cannot be changed it can be further instantiated as it happens to ordinary Prolog terms. Backtracking ensures they vanish so that no unsafe reference can be made to them.

The program lq8.pl is an efficient 8-queens program using global logical variables to simulate the chess-board.



next up previous
Next: 13.2 Garbage-collectible permanent objects. Up: 13 The Blackboard Previous: 13 The Blackboard



Paul Tarau
Thu Apr 3 10:26:39 AST 1997