Subject: RE: Modifying consulted rules

From: "Douglas Miles (Volt Computer)" <[email-masked]>
Date: Sat, 22 Jul 2000 09:47:02 -0700

Jason,
 
try this out and see if it is what you want...
 
in "consultTest.txt" put these 4 lines:
 
:-dynamic(test/1). % this will make sure it doesnt compile the test/1
predicates in this file
 
test(1).
test(original).
test(3).

open the standalone prolog shell..
 
?- consult('consultTest.txt') .  % or ['consultTest.txt'] would have done
the same.
?- listing(test).
test(1).
test(original).
test(3).
 
?- asserta(test(a)),assertz(test(z)).
?- retract(test(1)).
?- listing(test).
test(a).
test(original).
test(3).
test(z).
 
?- consult('consultTest.txt'), listing(test).
test(1).
test(original).
test(3).
 
?- assert(test(z)),listing(test).
test(1). 
test(original).
test(3).
test(z).
 
% now in the top of "consultTest.txt" put the line
 
 :-multifile(test/1).
 
?- consult('consultTest.txt'), listing(test).
test(z).
test(1). 
test(original).
test(3).

The problem you had ran into is when the file was consulted it also compiled
test/1. as static (static is default).
Since Prolog is a programming language as well as a smart database.. 
When I have a list of facts this is how i import them...
 
load_datafile(DataFile) :-
    see(DataFile),
    repeat,
        read(Datum),assert(Datum),
        Datum=end_of_file,seen,retract(Datum).   
                % the last 'retract' takes out the  end_of_file :)

Jan is there  implemented a 'Default consulting mode' flag somewhere that
can be defaulted to dynamic and/or multifile?

-----Original Message-----
From: Jason Che-han Yip [mailto:[email-masked]]
Sent: Saturday, July 22, 2000 9:14 AM
To: Douglas Miles (Volt Computer)
Subject: Re: Modifying consulted rules

Here's my test running SWI-Prolog stand-alone:
 
I have a file "consultTest.txt" with the fact test(original).
I consult this file.  listing shows that test(original) is now in the
database.
I try assert(test(new)) and I get ERROR: No permission to modify
static_procedure 'test_1'
 
So I try assert(newTest(old)), check listing, it's there.
Try assert(newTest(new)).  Checking listing shows both newTest(old) and
newTest(new)
----
So I figured that consulted facts/rules were un-modifiable but I didn't
think that was supposed to be the case?

----- Original Message ----- 
From: Douglas  <mailto:[email-masked]> Miles (Volt Computer) 
To: 'Jason Che-han Yip' <mailto:[email-masked]>  ; [email-masked]
<mailto:[email-masked]>  
Sent: Friday, July 21, 2000 5:06 PM
Subject: RE: Modifying consulted rules

"no permission to modify static procedures"
is ussuly due to a syntactical misplacement of a comma or semicollon in code
one missing period or one comma can make the prolog engine think you are
trying to add your own  version of  ','(_,_).