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
Next, the result is passed to expand_bodies/2, which performs goal
- expand_term(+Input, -Output) is det
- 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.
- var_property(+Var, ?Property)
- True when Var has a property Key with Value. Defined properties
- Variable is first introduced in this goal and thus guaranteed
to be unbound. This property is always present.
true indicate that the variable appears once in the source.
Note this doesn't mean it is a semantic singleton.
- True when Name is the name of the variable.
- expand_goal(+BodyTerm, +Pos0, -Out, -Pos) is det
- expand_goal(+BodyTerm, -Out) is det
- Perform macro-expansion on body terms by calling
- $expand_closure(+BodyIn, +ExtraArgs, -BodyOut) is semidet
- $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.
- function(?Term, +Context)[multifile]
- True if function expansion needs to be applied for the given
The following predicates are exported, but not or incorrectly documented.
- expand_goal(Arg1, Arg2)
- expand_term(Arg1, Arg2, Arg3, Arg4)