built-in method
current_predicate/1
ï
Descriptionï
current_predicate(Predicate)
Enumerates, by backtracking, visible, user-defined, object predicates. Built-in predicates and predicates not declared using a scope directive are not enumerated.
This predicate also succeeds for any predicates listed in uses/2 and use_module/2 directives.
When Predicate
is bound at compile-time to a (:)/2
term, this
predicate enumerates module predicates (assuming that the
backend Prolog compiler supports modules).
Modes and number of proofsï
current_predicate(?predicate_indicator) - zero_or_more
Errorsï
Predicate
is neither a variable nor a valid predicate indicator:type_error(predicate_indicator, Predicate)
Predicate
is a Name/Arity
term but Functor
is neither a variable nor an atom:type_error(atom, Name)
Predicate
is a Name/Arity
term but Arity
is neither a variable nor an integer:type_error(integer, Arity)
Predicate
is a Name/Arity
term but Arity
is a negative integer:domain_error(not_less_than_zero, Arity)
Examplesï
To enumerate, by backtracking, the locally visible user predicates or the user predicates visible in this:
current_predicate(Predicate)
To enumerate, by backtracking, the public and protected user predicates visible in self:
::current_predicate(Predicate)
To enumerate, by backtracking, the public user predicates visible for an explicit object:
Object::current_predicate(Predicate)
An example of enumerating locally visible object predicates. These include predicates listed using uses/2 and use_module/2 directives:
:- object(foo).
:- uses(bar, [
baz/1, quux/2
]).
:- public(pred/1).
pred(X) :-
current_predicate(X).
:- end_object.
| ?- foo::pred(X).
X = pred/1 ;
X = baz/1 ;
X = quux/2 ;
no
See also