Now I observed that transaction/1 does not rollback
predicate meta information. I get the following, with
snapshot/1 which does a rollback at end:
?- current_predicate(foo/1).
false.
?- snapshot(assertz(foo(bar))).
true.
?- current_predicate(foo/1).
true.
And with transaction/1 calling abort/0 to force a rollback:
?- current_predicate(foo/1).
false.
?- transaction((assertz(foo(bar)), abort)).
% Execution Aborted
?- current_predicate(foo/1).
true.
My expectation was rather that the last query gives false, i.e. that
the rollback also restores predicate existence, the example is also
only a monotonic change to meta information.
Edit 14.07.2022:
Looks like I can simulate SWI-Prolog snapshot/1 in Dogelog player
since this weekend.
snapshot(G) :-
current_prolog_flag(stage, S),
T is S+1,
set_prolog_flag(stage, T),
G,
sy_clear_stage, /* rollback */
set_prolog_flag(stage, S).
And it works differently, since I added meta information rollback.
?- current_predicate(foo/1).
fail.
?- snapshot(assertz(foo(bar))).
true.
?- current_predicate(foo/1).
fail. /* gives false in SWI-Prolog */
I do not have a commit statement yet, so I guess I cannot yet
simulate SWI-Prolog transaction/1.