### 8.8 Predicate information

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

#### 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:

- `static`: if the procedure is static.
- `dynamic`: if the procedure is dynamic.
- `private`: if the procedure is private.
- `public`: if the procedure is public.
- `monofile`: if the procedure is monofile.
- `multifile`: if the procedure is multifile.
- `user`: if the procedure is a user-defined procedure.
- `built_in`: if the procedure is a built-in predicate or a control construct.
- `built_in_fd`: if the procedure is an FD built-in predicate.
- `control_construct`: if the procedure is a control construct (section 7.2).
- `native_code`: if the procedure is compiled in native code.
- `prolog_file(File)`: source file from which the procedure has been read.
- `prolog_line(Line)`: line number of the source file.
- `meta_predicate(Head)`: if the procedure is a meta-predicate unify `Head` with the head-pattern. The head-pattern is a compound term with the same name and arity as the predicate where each argument of the term is a meta argument specifier as follows:
  integer `N`
    the argument is a term that is used to reference a predicate with `N` more arguments than the given argument term (e.g. `call(0)`).
  `:`
    the argument is module sensitive, but does not directly refer to a predicate (e.g. `consult(:)`).
  `-`
    the argument is not module sensitive and unbound on entry.
  `?`
    the argument is not module sensitive and the mode is unspecified.
  `+`
    the argument is not module sensitive and bound (i.e., nonvar) on entry.

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