Section "trailing"

The execution environment of Dogelog Player provides the state to drive a Prolog engine that is based on an iterative execution of either call ports of new goals, or if there was a failure redo ports of goals that were successful and left a choice point. The engine state responsible for this execution is the current continuation and the current choice point.

To deal with variable binding during unification the current trail is used. Choice points can keep pointers into the trail and allow to undo sections of variable binding. Because variables might become irrelevant during execution, the Prolog specific garbage collection called environment trimming aims at compacting the trail and thus saving memory.

Prolog variables store some colouring flags to manage generational garbage collection, and some serno which is used in lexical comparison. The serno once chosen during the creation of Prolog variable doesn’t change during environment trimming and therefore allows for certain algorithms, that other Prolog systems might not support.

The cross-compiler or runtime generate the following objects and calls:

new Variable(): (host language)
Create a Prolog variable.
new Compound(F, A): (host language)
Create a Prolog compound with functor F and arguments A.
new Choice(H, D, A, M): (host language)
Create a choice point with handler H, data D, index A and trail mark M.
get_cont(): (host language)
The function returns the current continuation.
cont(C): (host language)
The function sets the current continuation to C.
more(C): (host language)
The function sets the current choice point to C.
get_mark(): (host language)
The function returns the current trail.
unbind(M): (host language)
The function undoes variable binding up to the given trail mark.

Kommentare