current_predicate/[1,2] [ISO]current_predicate(?PredSpec)
Unifies PredSpec with a predicate specifications of the form Name/Arity.
current_predicate(?Name, ?Term)
Unifies Name with the name of a user-defined predicate, and Term with the most general term corresponding to that predicate.
If you have loaded the predicates foo/1 and foo/3 into Prolog,
current_predicate/2 would return the following:
| ?- current_predicate(foo, T).
T = foo(_A) ;
T = foo(_A,_B,_C) ;
no
| ?- current_predicate(Name, Module:Term).
| ?- current_predicate(Module:PredSpec).
current_predicate/[1,2] only succeeds for those predicates that are
defined in the module. It fails for those predicates that are imported
into a module.
| ?- current_predicate(m:P).
will backtrack through all predicates P that are defined in module m.
To backtrack through all predicates imported by a module use
predicate_property/2 (see ref-lps-ove).
To find out whether a predicate is built-in, use
predicate_property/2.
% Is there a callable predicate named gc?
| ?- current_predicate(gc, Term).
no
| ?- predicate_property(gc, Prop)
Prop = built_in
instantiation_errortype_errorcurrent_predicate/1 is part of the ISO Prolog standard; current_predicate/2 is not.
predicate_property/2, ref-lps-ove.