Did you know ... Search Documentation:
expand.pl -- Prolog source-code transformation
PublicShow source

This module specifies, together with dcg.pl, the transformation of terms as they are read from a file before they are processed by the compiler.

The toplevel is expand_term/2. This uses three other translators:

  • Conditional compilation
  • term_expansion/2 rules provided by the user
  • DCG expansion

Note that this ordering implies that conditional compilation directives cannot be generated by term_expansion/2 rules: they must literally appear in the source-code.

Term-expansion may choose to overrule DCG expansion. If the result of term-expansion is a DCG rule, the rule is subject to translation into a predicate.

Next, the result is passed to expand_bodies/2, which performs goal expansion.

Source expand_term(+Input, -Output) is det
Source expand_term(+Input, +Pos0, -Output, -Pos) is det
This predicate is used to translate terms as they are read from a source-file before they are added to the Prolog database.
Source var_property(+Var, ?Property)
True when Var has a property Key with Value. Defined properties are:
fresh(Fresh)
Variable is first introduced in this goal and thus guaranteed to be unbound. This property is always present.
singleton(Bool)
It true indicate that the variable appears once in the source. Note this doesn't mean it is a semantic singleton.
name(-Name)
True when Name is the name of the variable.
Source expand_goal(+BodyTerm, +Pos0, -Out, -Pos) is det
Source expand_goal(+BodyTerm, -Out) is det
Perform macro-expansion on body terms by calling goal_expansion/2.
Source $expand_closure(+BodyIn, +ExtraArgs, -BodyOut) is semidet
Source $expand_closure(+BodyIn, +PIn, +ExtraArgs, -BodyOut, -POut) is semidet
Expand a closure using goal expansion for some extra arguments. Note that the extra argument must remain at the end. If this is not the case, '$expand_closure'/3,5 fail.
Source function(?Term, +Context)[multifile]
True if function expansion needs to be applied for the given term.

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

Source $including
Source expand_goal(Arg1, Arg2)
Source expand_term(Arg1, Arg2, Arg3, Arg4)