instance/2

Synopsis

instance(+Ref, -Term)

Unifies Term with the most general instance of the dynamic clause or recorded term indicated by the database reference Ref.

Arguments


Ref db_reference

Term term

Description

Ref must be instantiated to a database reference to an existing clause or recorded term. instance/2 is not sensitive to the source module and can be used to access any clause, regardless of its module.

Exceptions


instantiation_error
if Ref is not instantiated
type_error
if Ref is not a syntactically valid database reference
existence_error
if Ref is a syntactically valid database reference but does not refer to an existing clause or recorded term.

Comments

instance/2 ignores the module of a clause. Because of this, accessing a clause with via instance/2 is different from accessing it via clause/3 with a given Ref.

If the reference is to a unit-clause C, then Term is unified with C :- true.

Examples

     | ?- assert(foo:bar,R).
     
     R = '$ref'(771292,1)
     
     | ?- instance('$ref'(771292,1),T).
     
     T = (bar:-true)
     
     | ?- clause(H,B,'$ref'(771292,1)).
     
     no
     | ?- clause(foo:H,B,'$ref'(771292,1)).
     
     H = bar,
     B = true
     
     | ?-
     

See Also

clause/3, asserta/2, assertz/2 ref-mdb-bas