Module stack

When a clause is invoked a special kind of a frame is created. Such a stack frame might have empty variable bindings or not yet a parent, so that the corresponding property might return missing elements. Besides that a stack frame constitutes an element of the ancestor goal list. It therefore provides additional properties such accessing the parent stack frame or the current call goal.

A stack frame where all the variable bindings are initially empty where there is no parent can be created with the predicate sys_prepare_clause/2. Such a stack frame can be executed by the predicate sys_unfold_body/1.

The following predicates for stack properties are provided:

sys_prepare_clause(R, F):
The predicate succeeds with a new stack frame reference F for the rule, fact or directive referenced by R.
sys_unfold_body(F):
The predicate succeeds whenever the directive of the stack frame F succeeds.

The following Prolog flags for stack properties are provided:

sys_query_frame:
The legal values are stack frames or the atom null. The value indicates the stack frame for the actual query. Default value is null. The value can be changed.

The following frame properties for stack properties are provided:

sys_parent_frame(F):
The property indicates that the stack frame has parent frame F. The property is single valued or can be missing. The property cannot be changed.
sys_call_goal(G):
The property indicates that the stack frame has call goal G. The property is single valued or can be missing. The property cannot be changed.

Comments