11.3.54 current_predicate/[1,2] [ISO]

Synopsis

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.

Arguments

:PredSpec
pred_spec
Name
atom
:Term
callable

Description

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

Examples

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

Exceptions

instantiation_error
type_error
in PredSpec

Comments

current_predicate/1 is part of the ISO Prolog standard; current_predicate/2 is not.

See Also

predicate_property/2, ref-lps-ove.


Send feedback on this subject.