PublicShow sourceapply_macros.pl -- Goal expansion rules to avoid meta-calling

This 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 auxilary 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.

author
- Jan Wielemaker
To be done
- Support more predicates
Source expand_phrase(+PhraseGoal, -Goal) is semidet
Source expand_phrase(+PhraseGoal, +Pos0, -Goal, -Pos) is semidet
Provide goal-expansion for PhraseGoal. PhraseGoal is either phrase/2,3 or call_dcg/2,3. The current version does not translate control structures, but only simple terminals and non-terminals.

For example:

?- expand_phrase(phrase(("ab", rule)), List), Goal).
Goal = (List=[97, 98|_G121], rule(_G121, [])).
throws
- Re-throws errors from dcg_translate_rule/2
Source expand_phrase(+PhraseGoal, -Goal) is semidet
Source expand_phrase(+PhraseGoal, +Pos0, -Goal, -Pos) is semidet
Provide goal-expansion for PhraseGoal. PhraseGoal is either phrase/2,3 or call_dcg/2,3. The current version does not translate control structures, but only simple terminals and non-terminals.

For example:

?- expand_phrase(phrase(("ab", rule)), List), Goal).
Goal = (List=[97, 98|_G121], rule(_G121, [])).
throws
- Re-throws errors from dcg_translate_rule/2