Dynamic predicates (not source preserving) (runtime)

Author(s): The Ciao Development Team.

This module implements the assert/retract family of predicates to manipulate dynamic predicates. This module does not preserve the original source definition of dynamic predicates.

Usage and interface

Documentation on exports

PREDICATEasserta/1

Usage:ISOasserta(Clause)

The current instance of Clause is interpreted as a clause and is added to the current program. The predicate concerned must be dynamic. The new clause becomes the first clause for the predicate concerned. Any uninstantiated variables in Clause will be replaced by new private variables.

Meta-predicate with arguments: asserta(clause).

PREDICATEasserta/2

Usage:asserta(Clause,Ref)

Like asserta/1. Ref is a unique identifier of the asserted clause.

Meta-predicate with arguments: asserta(clause,?).

PREDICATEassertz/1

Usage:ISOassertz(Clause)

Like asserta/1, except that the new clause becomes the last clause for the predicate concerned.

Meta-predicate with arguments: assertz(clause).

PREDICATEassertz/2

Usage:assertz(Clause,Ref)

Like assertz/1. Ref is a unique identifier of the asserted clause.

Meta-predicate with arguments: assertz(clause,?).

PREDICATEassert/1

Usage:assert(Clause)

Identical to assertz/1. Included for compatibility.

Meta-predicate with arguments: assert(clause).

PREDICATEassert/2

Usage:assert(Clause,Ref)

Identical to assertz/2. Included for compatibility.

Meta-predicate with arguments: assert(clause,?).

PREDICATEretract/1

Usage:ISOretract(Clause)

The first clause in the program that matches Clause is erased. The predicate concerned must be dynamic.

The predicate retract/1 may be used in a non-determinate fashion, i.e., it will successively retract clauses matching the argument through backtracking. If reactivated by backtracking, invocations of the predicate whose clauses are being retracted will proceed unaffected by the retracts. This is also true for invocations of clause for the same predicate. The space occupied by a retracted clause will be recovered when instances of the clause are no longer in use.

Meta-predicate with arguments: retract(clause).

PREDICATEretractall/1

Usage:retractall(Head)

Erase all clauses whose head matches Head, where Head must be instantiated to an atom or a compound term. The predicate concerned must be dynamic. The predicate definition is retained.

  • The following properties should hold at call time:
    (term_typing:nonvar/1)Head is currently a term which is not a free variable.
    (basic_props:callable/1)Head is a term which represents a goal, i.e., an atom or a structure.
  • The following properties should hold globally:
    (basic_props:native/1)This predicate is understood natively by CiaoPP.
Meta-predicate with arguments: retractall(fact).

PREDICATEabolish/1

Usage:ISOabolish(Spec)

Erase all clauses of the predicate specified by the predicate spec Spec. The predicate definition itself is also erased (the predicate is deemed undefined after execution of the abolish). The predicates concerned must all be user defined.

Meta-predicate with arguments: abolish(spec).

PREDICATEclause/2

Usage:ISOclause(Head,Body)

The clause 'Head :- Body' exists in the current program. The predicate concerned must be dynamic.

Meta-predicate with arguments: clause(fact,?).

PREDICATEclause/3
clause(Head,Body,Ref)

Like clause(Head,Body), plus the clause is uniquely identified by Ref.

Usage 1:clause(Head,Body,Ref)

Head must be instantiated to an atom or a compound term.

Usage 2:clause(Head,Body,Ref)

Ref must be instantiated to a valid identifier.

Meta-predicate with arguments: clause(fact,?,?).

Usage:ISOcurrent_predicate(Spec)

A predicate in the current module is named Spec.

  • The following properties should hold upon exit:
    (basic_props:predname/1)Spec is a predicate name.
  • The following properties should hold globally:
    (basic_props:native/1)This predicate is understood natively by CiaoPP.

Usage:current_predicate(Spec,Module)

A predicate in Module is named Spec. Module never is an engine module.

PREDICATEdynamic/1
dynamic(Spec)

Spec is of the form F/A. The predicate named F with arity A is made dynamic in the current module at runtime (useful for predicate names generated on-the-fly). If the predicate functor name F is uninstatiated, a new, unique, predicate name is generated at runtime.

Usage:dynamic(Spec)

PREDICATEdata/1
data(Spec)

Spec is of the form F/A. The predicate named F with arity A is made data in the current module at runtime (useful for predicate names generated on-the-fly). If the predicate functor name F is uninstatiated, a new, unique, predicate name is generated at runtime.

Usage:data(Spec)

wellformed_body(BodyIn,Env,BodyOut)

BodyIn is a well-formed clause body. BodyOut is its counterpart with no single-variable meta-goals (i.e., with call(X) for X). Env denotes if global cuts are admissible in BodyIn (+ if they are, - if they are not).

Documentation on multifiles

do_on_abolish(Head)

A hook predicate which will be called when the definition of the predicate of Head is abolished.

Usage:do_on_abolish(G)

  • The following properties should hold at call time:
    (basic_props:callable/1)G is a term which represents a goal, i.e., an atom or a structure.
The predicate is multifile.

Documentation on imports

This module has the following direct dependencies: