Availability:built-in
clause_property(+ClauseRef,
-Property)Queries properties of a clause. ClauseRef is a reference to a
clause as produced by clause/3, nth_clause/3
or
prolog_frame_attribute/3.
Unlike most other predicates that access clause references, clause_property/2
may be used to get information about erased clauses that have not yet
been reclaimed. Property is one of the following:
- file(FileName)
- Unify FileName with the name of the file from which the
clause is loaded. Fails if the clause was not created by loading a file
(e.g., clauses added using assertz/1).
See also
source
.
- line_count(LineNumber)
- Unify LineNumber with the line number of the clause. Fails if
the clause is not associated to a file.
- size(SizeInBytes)
- True when SizeInBytes is the size that the clause uses in
memory in bytes. The size required by a predicate also includes the
predicate data record, a linked list of clauses, clause selection
instructions and optionally one or more clause indexes.
- source(FileName)
- Unify FileName with the name of the source file that created
the clause. This is the same as the
file
property, unless
the file is loaded from a file that is textually included into source
using
include/1.
In this scenario, file
is the included file, while the source
property refers to the main file.
- fact
- True if the clause has no body.
- erased
- True if the clause has been erased, but not yet reclaimed because it is
referenced.
- predicate(PredicateIndicator)
- PredicateIndicator denotes the predicate to which this clause
belongs. This is needed to obtain information on erased clauses because
the usual way to obtain this information using clause/3
fails for erased clauses.
- module(Module)
- Module is the context module used to execute the body of the
clause. For normal clauses, this is the same as the module in which the
predicate is defined. However, if a clause is compiled with a module
qualified head, the clause belongs to the predicate with the
qualified head, while the body is executed in the context of the module
in which the clause was defined.