]> Repositorios git - scryer-prolog.git/commitdiff
move asserta/2, assertz/2 to iso_ext
authorMark Thom <[email protected]>
Thu, 10 Nov 2022 05:47:32 +0000 (06:47 +0100)
committerMark Thom <[email protected]>
Thu, 10 Nov 2022 05:47:32 +0000 (06:47 +0100)
src/lib/builtins.pl
src/lib/iso_ext.pl

index eab947cb158c301b106f9529cae30e21954f2646..1d2d0aed670b2fc2cf2cd9f5c65a0bcb22d7dfee 100644 (file)
@@ -1,13 +1,11 @@
 :- module(builtins, [(=)/2, (\=)/2, (\+)/1, !/0, (',')/2, (->)/2,
-                     (;)/2, (=..)/2, /* (:)/2, (:)/3, (:)/4, (:)/5,
-                     (:)/6, (:)/7, (:)/8, (:)/9, (:)/10, (:)/11,
-                     (:)/12, */ abolish/1, asserta/1, asserta/2,
-                     assertz/1, assertz/2, at_end_of_stream/0,
-                     at_end_of_stream/1, atom_chars/2, atom_codes/2,
-                     atom_concat/3, atom_length/2, bagof/3, call/1,
-                     call/2, call/3, call/4, call/5, call/6, call/7,
-                     call/8, call/9, callable/1, catch/3, char_code/2,
-                     clause/2, close/1, close/2, current_input/1,
+                     (;)/2, (=..)/2, abolish/1, asserta/1, assertz/1,
+                     at_end_of_stream/0, at_end_of_stream/1,
+                     atom_chars/2, atom_codes/2, atom_concat/3,
+                     atom_length/2, bagof/3, call/1, call/2, call/3,
+                     call/4, call/5, call/6, call/7, call/8, call/9,
+                     callable/1, catch/3, char_code/2, clause/2,
+                     close/1, close/2, current_input/1,
                      current_output/1, current_op/3,
                      current_predicate/1, current_prolog_flag/2,
                      error/2, fail/0, false/0, findall/3, findall/4,
@@ -59,66 +57,6 @@ call(_, _, _, _, _, _, _, _).
 
 call(_, _, _, _, _, _, _, _, _).
 
-% dynamic module resolution.
-
-/*
-
-Module : Predicate :-
-    (  atom(Module) -> '$module_call'(Module, Predicate)
-    ;  throw(error(type_error(atom, Module), (:)/2))
-    ).
-
-:(Module, Predicate, A1) :-
-    (  atom(Module) -> '$module_call'(Module, Predicate, A1)
-    ;  throw(error(type_error(atom, Module), (:)/2))
-    ).
-
-:(Module, Predicate, A1, A2) :-
-    (  atom(Module) -> '$module_call'(Module, Predicate, A1, A2)
-    ;  throw(error(type_error(atom, Module), (:)/2))
-    ).
-
-:(Module, Predicate, A1, A2, A3) :-
-    (  atom(Module) -> '$module_call'(Module, Predicate, A1, A2, A3)
-    ;  throw(error(type_error(atom, Module), (:)/2))
-    ).
-
-:(Module, Predicate, A1, A2, A3, A4) :-
-    (  atom(Module) -> '$module_call'(A4, Module, Predicate, A1, A2, A3)
-    ;  throw(error(type_error(atom, Module), (:)/2))
-    ).
-
-:(Module, Predicate, A1, A2, A3, A4, A5) :-
-    (  atom(Module) -> '$module_call'(Module, Predicate, A1, A2, A3, A4, A5)
-    ;  throw(error(type_error(atom, Module), (:)/2))
-    ).
-
-:(Module, Predicate, A1, A2, A3, A4, A5, A6) :-
-    (  atom(Module) -> '$module_call'(Module, Predicate, A1, A2, A3, A4, A5, A6)
-    ;  throw(error(type_error(atom, Module), (:)/2))
-    ).
-
-:(Module, Predicate, A1, A2, A3, A4, A5, A6, A7) :-
-    (  atom(Module) -> '$module_call'(Module, Predicate, A1, A2, A3, A4, A5, A6, A7)
-    ;  throw(error(type_error(atom, Module), (:)/2))
-    ).
-
-:(Module, Predicate, A1, A2, A3, A4, A5, A6, A7, A8) :-
-    (  atom(Module) -> '$module_call'(Module, Predicate, A1, A2, A3, A4, A5, A6, A7, A8)
-    ;  throw(error(type_error(atom, Module), (:)/2))
-    ).
-
-:(Module, Predicate, A1, A2, A3, A4, A5, A6, A7, A8, A9) :-
-    (  atom(Module) -> '$module_call'(Module, Predicate, A1, A2, A3, A4, A5, A6, A7, A8, A9)
-    ;  throw(error(type_error(atom, Module), (:)/2))
-    ).
-
-:(Module, Predicate, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) :-
-    (  atom(Module) -> '$module_call'(Module, Predicate, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)
-    ;  throw(error(type_error(atom, Module), (:)/2))
-    ).
-
-*/
 
 :- meta_predicate catch(0, ?, 0).
 
@@ -897,25 +835,14 @@ clause(H, B) :-
 
 asserta(Clause0) :-
     loader:strip_subst_module(Clause0, user, Module, Clause),
-    asserta(Module, Clause).
+    iso_ext:asserta(Module, Clause).
 
-asserta(Module, (Head :- Body)) :-
-    !,
-    '$asserta'(Module, Head, Body).
-asserta(Module, Fact) :-
-    '$asserta'(Module, Fact, true).
 
 :- meta_predicate assertz(:).
 
 assertz(Clause0) :-
     loader:strip_subst_module(Clause0, user, Module, Clause),
-    assertz(Module, Clause).
-
-assertz(Module, (Head :- Body)) :-
-    !,
-    '$assertz'(Module, Head, Body).
-assertz(Module, Fact) :-
-    '$assertz'(Module, Fact, true).
+    iso_ext:assertz(Module, Clause).
 
 
 :- meta_predicate retract(:).
index 1078cb27a1348ac1c09aa299454af4f66906fc03..26b4713c7b4ffc79a771ee1f8eafe622d142a0da 100644 (file)
@@ -9,7 +9,9 @@
                     partial_string_tail/2,
                     setup_call_cleanup/3,
                     call_nth/2,
-                    copy_term_nat/2]).
+                    copy_term_nat/2,
+                   asserta/2,
+                   assertz/2]).
 
 :- use_module(library(error), [can_be/2,
                                domain_error/3,
@@ -247,3 +249,17 @@ call_nth_nesting(C, ID) :-
 
 copy_term_nat(Source, Dest) :-
     '$copy_term_without_attr_vars'(Source, Dest).
+
+
+asserta(Module, (Head :- Body)) :-
+    !,
+    '$asserta'(Module, Head, Body).
+asserta(Module, Fact) :-
+    '$asserta'(Module, Fact, true).
+
+assertz(Module, (Head :- Body)) :-
+    !,
+    '$assertz'(Module, Head, Body).
+assertz(Module, Fact) :-
+    '$assertz'(Module, Fact, true).
+