Author(s): Angel Fernandez Pineda.
Version: 1.11#222 (2004/5/24, 13:8:7 CEST)
Version of last change: 1.11#16 (2003/4/8, 4:35:48 CEST)
This library offers a general way to perform clause body expansions. Goal, fact and spec translation predicates are authomatically called when needed, while this utility navigates through the meta-argument specification of the body itself. All predicates within this library must be called at second-pass expansions, since it uses information stored at
c_itf
library.
expansion_tools
)expansion_tools
)Macro provided in order to know meta-predicate specifications accessible from a module.
Usage: imports_meta_pred(Module, MetaSpec, AccessibleAt)
MetaSpec
meta-predicate specification is accessible from Module
. AccessibleAt
will be binded to '-' whether meta-predicate is a builtin one. If not, it will be unified with the module which defines the meta-predicate.
Module
is an atom.
(basic_props:atm/1
)
MetaSpec
is any term.
(basic_props:term/1
)
AccessibleAt
is a free variable.
(term_typing:var/1
)
This predicate is the main translation tool. It navigates through a clause body, when a single goal appears, user-code is called in order to perform a translation. Whether user-code fails to translate the involved goal, it remains the same. Regardless that goal is translated or not, an argument expansion will be performed over all goals if applicable (see
arg_expander/6
predicate).
Variable (unknown at compile time) goals will also be attempt to translate.
Meta-predicate with arguments: body_expander(pred(3),pred(3),pred(3),?,?,?)
.
Usage: body_expander(GoalTrans, FactTrans, SpecTrans, Module, Body, ExpandedBody)
Body
to ExpandedBody
by the usage of user-defined translators GoalTrans
, FactTrans
and SpecTrans
. The module where the original body appears must be unified with Module
argument.
GoalTrans
is a user-defined predicate which performs goal meta-type translation
(expansion_tools:goal_expander/1
)
FactTrans
is a user-defined predicate which performs fact meta-type translation
(expansion_tools:fact_expander/1
)
SpecTrans
is a user-defined predicate which performs spec meta-type translation
(expansion_tools:spec_expander/1
)
Module
is an atom.
(basic_props:atm/1
)
Body
is currently a term which is not a free variable.
(term_typing:nonvar/1
)
ExpandedBody
is a free variable.
(term_typing:var/1
)
This predicate is an auxiliary translation tool, which is used by
body_expander/6
predicate. It remains exported as a macro. The predicate navigates through the meta-argument specification of a goal. Whether a goal,fact or spec argument appears, user-code is called in order to perform a translation. Whether user-code fails to translate the involved argument, it remains the same. Builtins as ','/2 or ';'/2 are treated as meta-predicates defining goal meta-arguments. When a goal meta-argument is located,
body_expander/6
will be called in order to navigate through it. Notice that a goal meta-argument may be unified with another goal defining another meta-argument, so navigation is required. If arguments are not known to arg_expander/6, translation will not occur. This is posible whether goal or qualifing module are variables.
Meta-predicate with arguments: arg_expander(pred(3),pred(3),pred(3),?,?,?)
.
Usage: arg_expander(GoalTrans, FactTrans, SpecTrans, Module, Goal, ExpandedGoal)
Goal
to ExpandedGoal
by applying user-defined translators (GoalTrans
, FactTrans
and SpecTrans
) to each meta-argument present at such goal. The module where the original goal appears must be unified with Module
argument.
GoalTrans
is a user-defined predicate which performs goal meta-type translation
(expansion_tools:goal_expander/1
)
FactTrans
is a user-defined predicate which performs fact meta-type translation
(expansion_tools:fact_expander/1
)
SpecTrans
is a user-defined predicate which performs spec meta-type translation
(expansion_tools:spec_expander/1
)
Module
is an atom.
(basic_props:atm/1
)
Goal
is currently a term which is not a free variable.
(term_typing:nonvar/1
)
ExpandedBody
is a free variable.
(term_typing:var/1
)
expansion_tools
)
Usage: expander_pred(Pred)
Pred
is a user-defined predicate used to perform code translations. First argument will be binded to the corresponding term to be translated. Second argument must be binded to the corresponding translation. Third argument will be binded to the current module were first argument appears. Additional arguments will be user-defined.
expansion_tools
)Go to the first, previous, next, last section, table of contents.