Skip to content

Commit

Permalink
Fix clpb blackboard problem, re issue #338
Browse files Browse the repository at this point in the history
  • Loading branch information
infradig committed Oct 6, 2023
1 parent 78846ac commit 3cee5d1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
16 changes: 9 additions & 7 deletions library/builtins.pl
Original file line number Diff line number Diff line change
Expand Up @@ -662,31 +662,33 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% SICStus compatible

% TODO: should be per-module key

bb_put(K, V) :-
must_be(K, atomic, bb_put/2, _),
ignore(retract('$bb_key'(K, _, _))),
asserta('$bb_key'(K, V, nb)).
ignore(retract(user:'$bb_key'(K, _, _))),
asserta(user:'$bb_key'(K, V, nb)).

:- help(bb_put(+atomic,+term), [iso(false)]).

bb_get(K, V) :-
must_be(K, atomic, bb_get/2, _),
'$bb_key'(K, V, _),
user:'$bb_key'(K, V, _),
!.

:- help(bb_get(+atomic,?term), [iso(false)]).

bb_delete(K, V) :-
must_be(K, atomic, bb_delete/2, _),
retract('$bb_key'(K, V, _)),
retract(user:'$bb_key'(K, V, _)),
!.

:- help(bb_delete(+atomic,+term), [iso(false)]).

bb_update(K, O, V) :-
must_be(K, atomic, bb_update/3, _),
ignore(retract('$bb_key'(K, O, _))),
asserta('$bb_key'(K, V, nb)),
ignore(retract(user:'$bb_key'(K, O, _))),
asserta(user:'$bb_key'(K, V, nb)),
!.

:- help(bb_update(+atomic,+term,+term), [iso(false)]).
Expand All @@ -695,7 +697,7 @@

bb_b_put(K, V) :-
must_be(K, atomic, bb_b_put/2, _),
asserta('$bb_key'(K, V, b), Ref),
asserta(user:'$bb_key'(K, V, b), Ref),
'$quantum_eraser'(_, Ref).

:- help(bb_b_put(+atomic,+term), [iso(false)]).
Expand Down
6 changes: 6 additions & 0 deletions src/predicates.c
Original file line number Diff line number Diff line change
Expand Up @@ -2113,6 +2113,12 @@ static bool fn_iso_clause_2(query *q)

bool do_retract(query *q, cell *p1, pl_idx p1_ctx, enum clause_type is_retract)
{
if (p1->val_off == g_colon_s) {
p1 = p1 + 1;
q->st.m = find_module(q->pl, C_STR(q, p1));
p1 += p1->nbr_cells;
}

if (!q->retry) {
cell *head = deref(q, get_head(p1), p1_ctx);

Expand Down

0 comments on commit 3cee5d1

Please sign in to comment.