Home Contents Index Summary Previous Next

A.1 Examining the Environment Stack

prolog_current_frame(-Frame)
Unify Frame with an integer providing a reference to the parent of the current local stack frame. A pointer to the current local frame cannot be provided as the predicate succeeds deterministically and therefore its frame is destroyed immediately after succeeding.

prolog_frame_attribute(+Frame, +Key, -Value)
Obtain information about the local stack frame Frame. Frame is a frame reference as obtained through prolog_current_frame/1, prolog_trace_interception/4 or this predicate. The key values are described below.

alternative
Value is unified with an integer reference to the local stack frame in which execution is resumed if the goal associated with Frame fails. Fails if the frame has no alternative frame.

has_alternatives
Value is unified with true if Frame still is a candidate for backtracking. false otherwise.

goal
Value is unified with the goal associated with Frame. If the definition module of the active predicate is not user the goal is represented as <module>:<goal>. Do not instantiate variables in this goal unless you know what you are doing!

clause
Value is unified with a reference to the currently running clause. Fails if the current goal is associated with a foreign (C) defined predicate. See also nth_clause/3 and clause_property/2.

level
Value is unified with the recursion level of Frame. The top level frame is at level `0'.

parent
Value is unified with an integer reference to the parent local stack frame of Frame. Fails if Frame is the top frame.

context_module
Value is unified with the name of the context module of the environment.

top
Value is unified with true if Frame is the top Prolog goal from a recursive call back from the foreign language. false otherwise.

hidden
Value is unified with true if the frame is hidden from the user, either because a parent has the hide-childs attribute (all system predicates), or the system has no trace-me attribute.

pc
Value is unified with the program-pointer saved on behalve of the parent-goal if the parent-goal is not owned by a foreign predicate.

argument(N)
Value is unified with the N-th slot of the frame. Argument 1 is the first argument of the goal. Arguments above the arity refer to local variables. Fails silently if N is out of range.