Did you know ... | Search Documentation: |
Packs (add-ons) for SWI-Prolog |
Title: | Call a Goal with local assertions |
---|---|
Rating: | Not rated. Create the first rating! |
Latest version: | 1.2.111 |
SHA1 sum: | d8733f5fd197869468497bbfdd97df36c63dd532 |
Author: | Douglas R. Miles <logicmoo@gmail.com> |
Maintainer: | TeamSPoon https://github.com/TeamSPoon/ |
Packager: | TeamSPoon/LogicMoo https://github.com/TeamSPoon/ |
Home page: | https://github.com/TeamSPoon/with_thread_local |
Download URL: | https://github.com/TeamSPoon/with_thread_local/releases/*.zip |
Requires: | logicmoo_utils |
No reviews. Create the first review!.
Version | SHA1 | #Downloads | URL |
---|---|---|---|
1.1.112 | 70ac617e658c5c1deda0ab278b54c50509aea3fc | 1 | https://github.com/TeamSPoon/with_thread_local.git |
1.1.115 | fd6734e330581093fffca255fc1c9300283b1e9d | 1 | https://github.com/TeamSPoon/with_thread_local.git |
1.1.117 | 7143ed10bf0b0d5448938d2fb7bba6bb105825ee | 1 | https://github.com/TeamSPoon/with_thread_local.git |
1.1.118 | c738a6e9150a5dcdb55504f394be0c87e0fcb3a7 | 1 | https://github.com/TeamSPoon/with_thread_local.git |
1.2.111 | bbd79be97d825166be4bca426598594a7cf0a8ff | 5 | https://github.com/TeamSPoon/with_thread_local.git |
d8733f5fd197869468497bbfdd97df36c63dd532 | 6 | https://github.com/TeamSPoon/with_thread_local.git |
Call a Goal with local assertions
Installation using SWI-Prolog 7.1 or later:
`?- pack_install('https://github.com/TeamSPoon/with_thread_local.git'). `
Source code available and pull requests accepted at http://github.com/logicmoo/with_thread_local
locally_each( :Effect, :Call) is nondet.
Temporally have :Effect (see locally/2)
But Ensure Non-determism is respected (effect is undone between each Redo)
uses each_call_cleanup/3 instead of setup_call_cleanup/3 (slightly slower?)
for example,
locally_each/2 works (Does not throw)
?- current_prolog_flag(xref,Was), locally_each(set_prolog_flag(xref,true), assertion(current_prolog_flag(xref,true));assertion(current_prolog_flag(xref,true))), assertion(current_prolog_flag(xref,Was)),fail.
locally/2 is little less carefull so it should not work (it throws instead)
?- current_prolog_flag(xref,Was), locally(set_prolog_flag(xref,true), assertion(current_prolog_flag(xref,true));assertion(current_prolog_flag(xref,true))), assertion(current_prolog_flag(xref,Was)),fail.
locally( :Effect, :Call) is nondet.
Effect may be of type:
set_prolog_flag - Temporarily change prolog flag
op/3 - change op
$gvar=Value - set a global variable
Temporally (thread_local) Assert some :Effect
use locally_each/3 if respecting Non-determism is important (slightly slower?)
?- current_prolog_flag(xref,Was), locally(set_prolog_flag(xref,true), assertion(current_prolog_flag(xref,true))), assertion(current_prolog_flag(xref,Was)).
Document this pack!
Write tests
Untangle the 'pack' install deps (Moving predicates over here from logicmoo_base)
Dislike having tons of forks that are several commits behind the main git repo?
Be old school - Please ask to be added to TeamSPoon and Contribute directly !
Still, we wont stop you from doing it the Fork+PullRequest method
Copyright (c) 2017, TeamSPoon and Douglas Miles <logicmoo@gmail.com> All rights reserved.
Pack contains 5 files holding a total of 4.2K bytes.