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
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.
hash(Buckets, Speedup, IsList). Here Buckets is the number of buckets in the hash and Speedup is the expected speedup relative to trying all clauses linearly. IsList indicates that a list is created for all clauses with the same key. This is currently not used.
fileproperty above, notably the reference to clause_property/2.
true(i.e., a fact). Fails for foreign predicates. This property is used to avoid analysing predicates with only facts in
dynamic, i.e., for each defined predicate, either
dynamicis true but never both.
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.