|Did you know ...||Search Documentation:|
|Examining the program|
t(Name, Arity) :- ( current_functor(Name, Arity) -> current_functor(N, A), N == Name, A == Arity ; true ).
If PredicateIndicator is not fully specified, the
predicate only generates values that are defined in or already imported
into the target module. Generating all callable predicates therefore
requires enumerating modules using current_module/1.
Generating predicates callable in a given module requires enumerating
the import modules using import_module/2
and the autoloadable predicates using the
call_if_exists(G) :- current_predicate(_, G), call(G).
Because of this intended usage, current_predicate/2 also succeeds if the predicate can be autoloaded. Unfortunately, checking the autoloader makes this predicate relatively slow, in particular because a failed lookup of the autoloader will cause the autoloader to verify that its index is up-to-date.
generate_built_in(Name/Arity) :- predicate_property(system:Head, built_in), functor(Head, Name, Arity), \+ sub_atom(Name, 0, _, _, $). % discard reserved names
The predicate predicate_property/2 is covered by part-II of the ISO standard (modules). Although we are not aware of any Prolog system that implements part-II of the ISO standard, predicate_property/2 is available in most systems. There is little consensus on the implemented properties though. SWI-Prolog's auto loading feature further complicate this predicate.
Property is one of:
undefined, this property is not generated.
line_count. Note that this reports the file of the first clause of a predicate. A more robust interface can be achieved using nth_clause/3 and clause_property/2.
failin the target module.
Index is a term
hash(Buckets, Speedup, Size, IsList).
Buckets is the number of buckets in the hash and Speedup
is the expected speedup relative to trying all clauses linearly, Size
is the size of the index in memory in bytes and finally, IsList
indicates that a list is created for all clauses with the same key. This
is used to create deep indexes for the arguments of compound
Note: This predicate property should be used for analysis and statistics only. The exact representation of Indexes may change between versions. The utilities jiti_list/0 jiti_list/1 list the jit indexes of matching predicates in a user friendly way.
fileproperty above, notably the reference to clause_property/2.
number_of_clauses(ClauseCount), but only counts rules. A rule is defined as a clauses that has a body that is not just
true(i.e., a fact).
indexed(Indexes)property. Excluded are lingering data structures. These are garbage data structures that have been detached from the predicate but cannot yet be reclaimed because they may be in use by some thread.
dynamic, i.e., for each defined predicate, either
dynamicis true but never both.
tabled(?Flag)property can be used to obtain details about how the predicate is tabled.
subsumptive. In addition, tabled predicates may have one or more of the following flags
tabled property to enumerate all tabled
meta_predicate(Head)is also provided. See chapter 6 for details.
visibleis provided explicitly. If the property is left unbound, only defined predicates are enumerated.
system(see access_level). Backtracking provides all alternative matches.
?- use_module(library(lists)). ... ?- nth_clause(append(_,_,_), 2, Ref), clause(Head, Body, Ref). Ref = <clause>(0x994290), Head = lists:append([_G23|_G24], _G21, [_G23|_G27]), Body = append(_G24, _G21, _G27).
fileproperty, unless the file is loaded from a file that is textually included into source using include/1. In this scenario,
fileis the included file, while the
sourceproperty refers to the main file.