Previous Up Next

8.8  Predicate information

8.8.1  current_predicate/1

Templates

current_predicate(?predicate_indicator)

Description

current_predicate(Pred) succeeds if there exists a predicate indicator of a defined procedure that unifies with Pred. All user defined procedures are found, whether static or dynamic. Internal system procedures whose name begins with ’$’ are not found. A user-defined procedure is found even when it has no clauses. A user-defined procedure is not found if it has been abolished. To conform to the ISO reference, built-in predicates are not found except if the strict_iso Prolog flag is switched off (section 8.22.1). This predicate is re-executable on backtracking.

Errors

Pred is neither a variable nor a predicate indicator  type_error(predicate_indicator, Pred)
Pred is a term Name/Arity and Arity is neither a variable nor an integer  type_error(integer, Arity)
Pred is a term Name/Arity and Name is neither a variable nor an atom  type_error(atom, Name)
Pred is a term Name/Arity and Arity is an integer < 0  domain_error(not_less_than_zero, Arity)
Pred is a term Name/Arity and Arity is an integer > max_arity flag (section 8.22.1)  representation_error(max_arity)

Portability

ISO predicate.

8.8.2  predicate_property/2

Templates

predicate_property(?callable, ?predicate_property)

Description

predicate_property(Head, Property) succeeds if Head refers to a predicate that has a property Property. All user defined procedures and built-in predicates are found. Internal system procedures whose name begins with ’$’ are not found. This predicate is re-executable on backtracking.

Since version 1.4.0, predicate_property/2 no longer accepts a predicate indicator. Control constructs are now returned. Properties built_in_fd and control_construct now imply the property built_in.

Predicate properties:

Errors

Head is neither a variable nor a callable term  type_error(callable, Head)
Property is neither a variable nor a predicate property term  domain_error(predicate_property, Property)
Property = prolog_file(File) and File is neither a variable nor an atom  type_error(atom, File)
Property = prolog_line(Line) and Line is neither a variable nor an integer  type_error(integer, Line)

Portability

GNU Prolog predicate.


Copyright (C) 1999-2013 Daniel Diaz Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved. More about the copyright
Previous Up Next