Skip to content

Commit

Permalink
Merge pull request #2177 from mthom/remove_assertx
Browse files Browse the repository at this point in the history
Remove assert(a,z)/2 (#1975)
  • Loading branch information
mthom authored Nov 22, 2023
2 parents ef8eb93 + 2811660 commit 20da342
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
15 changes: 13 additions & 2 deletions src/lib/builtins.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1173,8 +1173,13 @@
% The clause will be inserted at the beginning of the module.
asserta(Clause0) :-
loader:strip_subst_module(Clause0, user, Module, Clause),
iso_ext:asserta(Module, Clause).
asserta_(Module, Clause).

asserta_(Module, (Head :- Body)) :-
!,
'$asserta'(Module, Head, Body).
asserta_(Module, Fact) :-
'$asserta'(Module, Fact, true).

:- meta_predicate assertz(:).

Expand All @@ -1184,7 +1189,13 @@
% The clase will be inserted at the end of the module.
assertz(Clause0) :-
loader:strip_subst_module(Clause0, user, Module, Clause),
iso_ext:assertz(Module, Clause).
assertz_(Module, Clause).

assertz_(Module, (Head :- Body)) :-
!,
'$assertz'(Module, Head, Body).
assertz_(Module, Fact) :-
'$assertz'(Module, Fact, true).


:- meta_predicate retract(:).
Expand Down
22 changes: 1 addition & 21 deletions src/lib/iso_ext.pl
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
succ/2,
call_nth/2,
countall/2,
copy_term_nat/2,
asserta/2,
assertz/2]).
copy_term_nat/2]).

:- use_module(library(error), [can_be/2,
domain_error/3,
Expand Down Expand Up @@ -384,21 +382,3 @@
copy_term_nat(Source, Dest) :-
'$copy_term_without_attr_vars'(Source, Dest).

%% asserta(Module, Rule_Fact).
%
% Similar to `asserta/1` but allows specifying a Module
asserta(Module, (Head :- Body)) :-
!,
'$asserta'(Module, Head, Body).
asserta(Module, Fact) :-
'$asserta'(Module, Fact, true).

%% assertz(Module, Rule_Fact).
%
% Similar to `assertz/1` but allows specifying a Module
assertz(Module, (Head :- Body)) :-
!,
'$assertz'(Module, Head, Body).
assertz(Module, Fact) :-
'$assertz'(Module, Fact, true).

0 comments on commit 20da342

Please sign in to comment.