| Did you know ... | Search Documentation: |
| Pack redcg -- prolog/redcg.pl |
Write multi-accumulator predicates in EDCG's surface syntax — the declarations
acc_info/5, pass_info/1, pred_info/3 and -->> rules
with [Term]:Acc (accumulate), bare [Term] (accumulate onto the built-in
dcg list), X/Acc (read current), Acc/X (read final), X/Acc/Y (read both)
and insert/2 — but have them expand onto Peter Ludemann's record-threading
technique: all hidden state is packed into a single :- record term
(library(record)) threaded through one hidden In/Out pair, with every field
read/write inlined to plain unification at expansion time.
Backwards compatibility with library(edcg). An EDCG program should run under
redcg by swapping library(edcg) for library(redcg) and the `edcg:`
declaration prefix for `redcg:`. redcg matches EDCG on: the built-in dcg
accumulator, bare-list terminals, the [T]:Acc / X/Acc / Acc/X / X/Acc/Y
/ insert/2 operators, cuts and {} in bodies, arbitrary-arity base
predicates, and the per-accumulator In/Out public-argument convention
(accumulator = +2 args, passed arg = +1, in pred_info order). Accumulator
direction follows your acc_info/5 declaration positionally, exactly as EDCG.
Like EDCG, this module exports nothing but its operators and the opt-in sentinel. Declarations are `redcg:`-qualified multifile facts:
redcg:acc_info(count, X, In, Out, plus(X, In, Out)). redcg:pass_info(limit). redcg:pred_info(sum_e, 1, [count]).
Enable expansion in a module by importing this one (:- use_module(library(redcg)));
the import is the opt-in signal, exactly as EDCG uses its own sentinel.
See README.md for the design write-up and the honest EDCG-vs-record benchmark.
The following predicates are exported, but not or incorrectly documented.