| Did you know ... | Search Documentation: |
| Packs (add-ons) for SWI-Prolog |
| Title: | Hash-consed terms by clause rewriting |
|---|---|
| Rating: | Not rated. Create the first rating! |
| Latest version: | 0.1.0 |
| SHA1 sum: | 38fa1bc6efb5cedc37ebb98997c768e1fe713137 |
| Author: | Yang, Bo <yang-bo@yang-bo.com> |
| Home page: | https://github.com/Atry/hash_consing |
| Download URL: | https://github.com/Atry/hash_consing.git |
No reviews. Create the first review!.
| Version | SHA1 | #Downloads | URL |
|---|---|---|---|
| 0.1.0 | 38fa1bc6efb5cedc37ebb98997c768e1fe713137 | 2 | https://github.com/Atry/hash_consing.git |

Hash-consed terms for SWI-Prolog, and a load-time rewrite that makes a program use them. A file is written as the program that does not intern and names the constructors to intern; every clause read after that directive refers to their instances by Ids, each wrapping a node handle of one trie, and the store is canonical: the same term has the same Id.
?- pack_install(hash_consing).
:- module(steps, [step/2, built/2]).
:- use_module(library(hash_consing), []).
:- hash_consing:rewritten([apply(*, _), lambda(_), variable(_)]).
step(apply(lambda(Body), Argument), beta(Body, Argument)).
built(Function, Applied) :-
Applied = apply(Function, variable(0)).
A term that did not come through the rewrite crosses the boundary with
internalized/3, and externalized/2 turns Ids back
into terms. The module comment of prolog/hash_consing.pl
is the reference: the relation intern/2, the Id and its shape, the
templates, the rewrite of a clause, the two rules for a file that opts in,
and the known defects.
test/hash_consing_rewrite.sh | diff - test/hash_consing_rewrite_baseline.txt
prints nothing when the rewrite and intern/2 behave as specified.
Open pull requests against main. main changes only by merging a pull
request with a merge commit, and every merge into main is a release:
CI runs `swipl pack publish` on the merged main, which tags `V<version>`
from the version/1 of pack.pl, installs the pack from this repository
in an isolated directory and registers it with the SWI-Prolog pack server.
A pull request into main must therefore raise version/1 above every
released version; a required check enforces it.
MIT. See [LICENSE](LICENSE).
Pack contains 14 files holding a total of 77.3K bytes.