Given a table entry
(S,, Status), each answer in
is
maintained in XSB as an answer substitution, that is a
substitution to the variables of S. The table inspection predicates
allow access to answer substitutions through a term whose principle
functor is ret/n, where n is the number of distinct variables
in the producer subgoal. The order of arguments in ret/n
corresponds to the order of distinct variables in a left-to-right
traversal of S.
In a similar manner, XSB maintains substitutions between producer subgoals and consuming subgoals when subsumption-based tabling is used. The return template for a consuming call is a substitution mapping variables of its producer to subterms of the call. This template can then be used to select returns from the producer which satisfy the consuming call. Note, then, that a return template of a subsumed subgoal may show partial instantiations. Return templates are also represented as ret/n terms in the manner described above.