7.8 | Predicate information

- `current_predicate/1`
- `predicate_property/2`

7.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 7.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 7.22.1) |  | `representation_error(max_arity)`

Portability
ISO predicate.

7.8.2 | `predicate_property/2`

Templates

  `predicate_property(?predicate_indicator, ?predicate_property)`

Description
`predicate_property(Pred, Property)` succeeds if there exists a predicate indicator of a defined procedure that unifies with `Pred` and if `Property` unifies with one of the properties of the procedure. 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.
Predicate properties:

- `static`: if the procedure is static.
- `dynamic`: if the procedure is dynamic.
- `private`: if the procedure is private.
- `public`: if the procedure is public.
- `user`: if the procedure is a user-defined procedure.
- `built_in`: if the procedure is a Prolog built-in predicate.
- `built_in_fd`: if the procedure is an FD built-in predicate.
- `native_code`: if the procedure is compiled in native code.
- `prolog_file(File)`: source file from which the predicate has been read.
- `prolog_line(Line)`: line number of the source file.

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 7.22.1) |  | `representation_error(max_arity)`

`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-2002 Daniel Diaz
Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.
More about the copyright