![]() |
YAP 7.1.0
|
Predicates in YAP may be dynamic or static. More...
Predicates in YAP may be dynamic or static.
Next follow the main operations on dynamic predicates.
By default, when consulting or reconsulting, predicates are assumed to be static: execution is faster and the code will probably use less space Static predicates impose some restrictions: in general there can be no addition or removal of clauses for a procedure if it is being used in the current execution
Dynamic predicates allow programmers to change the Clausal Data Base with the same flexibility as in C-Prolog With dynamic predicates it is always possible to add or remove clauses during execution and the semantics will be the same as for C-Prolog But the programmer should be aware of the fact that asserting or retracting are still expensive operations, and therefore he should try to avoid them whenever possible
class asserta/1 |
asserta(+ C)
defined in the ISO standard
Adds clause C to the beginning of the program If the predicate is undefined, it is declared dynamic (see dynamic/1 )
class assertz/1 |
assertz(+ C)
defined in the ISO standard
Adds clause C to the end of the program If the predicate is undefined, it is declared dynamic (see dynamic/1 )
Most Prolog systems only allow asserting clauses for dynamic predicates This is also as specified in the ISO standard YAP also allows asserting clauses for static predicates, under the restriction that the static predicate may not be live in the stacks
class assert/1 |
assert(+ C)
Same as assertz/1 Adds clause C to the program If the predicate is undefined, declare it as dynamic New code should use assertz/1 for better portability
Most Prolog systems only allow asserting clauses for dynamic predicates This is also as specified in the ISO standard YAP allows asserting clauses for static predicates, as long as the predicate is not in use and the language flag is cprolog
Note that this feature is deprecated, if you want to assert clauses for static procedures you should use assert_static/1
class asserta/2 |
asserta(+ C,- R)
The same as asserta(C)
but unifying R with the database reference that identifies the new clause, in a one-to-one way Note that asserta/2
only works for dynamic predicates If the predicate is undefined, it will automatically be declared dynamic
Definition at line 1 of file preddyns.yap.
class assertz/2 |
assertz(+ C,- R)
The same as assertz(C)
but unifying R with the database reference that identifies the new clause, in a one-to-one way Note that asserta/2
only works for dynamic predicates If the predicate is undefined, it will automatically be declared dynamic
class assert/2 |
assert(+ C,- R)
The same as assert(C)
( (see Modifying the Database)) but unifies R with the database reference that identifies the new clause, in a one-to-one way Note that asserta/2
o>ly works for dynamic predicates If the predicate is undefined, it will automatically be declared dynamic
class retract/1 |
retract(+ C)
defined in the ISO standard
Erases the first clause in the program that matches C This predicate may also be used for the static predicates that have been compiled when the source mode was on
For more information on source/0 ( (see Setting the Compiler))
class retract/2 |
retract(+ C,- R)
Erases from the program the clause C whose database reference is R The predicate must be dynamic
class retractall/1 |
retractall(+ G)
defined in the ISO standard
Retract all the clauses whose head matches the goal G Goal G must be a call to a dynamic predicate
class dynamic_predicate/2 |
dynamic_predicate(+ P,+ Semantics)
Declares predicate P or list of predicates [ P1,..., Pn] as a dynamic predicate following either logical
or immediate
semantics