
apply_macros.pl -- Goal expansion rules to avoid meta-callingThis module defines goal_expansion/2 rules to deal with commonly used, but fundamentally slow meta-predicates. Notable maplist/2... defines a useful set of predicates, but its execution is considerable slower than a traditional Prolog loop. Using this library calls to maplist/2... are translated into an call to a generated auxiliary predicate that is compiled using compile_aux_clauses/1. Currently this module supports:
The idea for this library originates from ECLiPSe and came to SWI-Prolog through YAP.
expand_maplist(+Callable, +Lists, -Goal) is det[private]
maplist_extend_goal(+Closure, +Args, -Goal) is semidet[private]
expand_closure_no_fail(+Goal, +Extra:integer, -GoalExt) is det[private]
expand_apply(+GoalIn:callable, -GoalOut) is semidet[private]
expand_apply(+GoalIn:callable, -GoalOut, +PosIn, -PosOut) is semidet[private]once(Goal) cannot be
translated to (Goal->true) because this will break the
compilation of (once(X) ; Y). A correct translation is to
(Goal->true;fail). Abramo Bagnara suggested
((Goal->true),true), which is both faster and avoids warning
if style_check(+var_branches) is used.
expand_phrase(+PhraseGoal, -Goal) is semidet
expand_phrase(+PhraseGoal, +Pos0, -Goal, -Pos) is semidetFor example:
?- expand_phrase(phrase(("ab", rule)), List), Goal).
Goal = (List=[97, 98|_G121], rule(_G121, [])).
dcg_extend(+Callable, +Pos0, -Goal, -Pos, +Xs0, ?Xs) is semidet[private]
qcall_instantiated(@Term) is semidet[private]
apply_macros_sentinelapply_macros is set to imported.The following predicates are exported from this file while their implementation is defined in imported modules or non-module files loaded by this module.
expand_phrase(+PhraseGoal, -Goal) is semidet
expand_phrase(+PhraseGoal, +Pos0, -Goal, -Pos) is semidetFor example:
?- expand_phrase(phrase(("ab", rule)), List), Goal).
Goal = (List=[97, 98|_G121], rule(_G121, [])).