Module ref

The predicates assertable_ref/2 and assumable_ref/2 allow the compilation of a clause without any thread contention. The clause can be associated and de-associated with the head predicate via the predicates recorda_ref/1, recordz_ref/1 and erase_ref/1 whereby only one thread will win. A new instance of the original clause can be retrieved again by the predicate compiled_ref/2.

The predicate clause_ref/3 can be used to find a clause in the knowledge base. This predicate respects the logical view approach form the ISO core Prolog standard. The predicate will further filter and only return those clauses that are visible from the head predicate that is used in the search. The predicate additionally returns clauses that can be used with the other predicates here.

The predicates ref_property/2, set_ref_property/2 and reset_re_property/2 allow inspecting and modifying clause properties. Clause references might not only refer to clauses, they implement a more general base class. Clause references are for example used in the Jekejeke Minlog extension to refer to attributed variable slots.

The following clause reference predicates are provided:

assertable_ref(C, R):
The predicate compiles the term C into a new clause reference R. An undefined or unimplemented head predicate will be turned into a dynamic predicate. Otherwise the head predicate must be dynamic or thread local.
assumable_ref(C, R):
The predicate compiles the term C into a new clause reference R. An undefined or unimplemented head predicate will be turned into a thread local predicate. Otherwise the head must be dynamic or thread local.
recorda_ref(R):
The predicate inserts the clause referenced by R at the top. The predicate fails when the clause has already been recorded.
recordz_ref(R):
The predicate inserts the clause referenced by R at the bottom. The predicate fails when the clause has already been recorded.
erase_ref(R):
The predicate removes the clause referenced by R. The predicate fails when the clause has already been erased.
compiled_ref(R, C):
The predicate returns a copy of the term C that was compiled into the clause reference R.
clause_ref(H, B, R):
The predicate succeeds with the user clauses that match H :- B and the clause reference R of the user clause. The head predicate must be dynamic or thread local.
clause_ref(C, R):
The predicate succeeds with the user clauses that match C and the clause reference R of the user clause. The head predicate must be dynamic or thread local.
ref_property(R, P):
The predicate succeeds for the properties P of the reference R.
set_ref_property(R, P):
The predicate assigns the property P to the reference R.
reset_ref_property(R, P):
The predicate de-assigns the property P from the reference R.

Kommentare