From a-doug@microsoft.com Sat Jul 22 19:42:48 2000 Received: from mail2.microsoft.com (mail2.microsoft.com [131.107.3.124]) by swi.psy.uva.nl (8.9.3/8.9.3) with SMTP id TAA24296 for ; Sat, 22 Jul 2000 19:42:47 +0200 (MET DST) Received: from 157.54.9.104 by mail2.microsoft.com (InterScan E-Mail VirusWall NT); Sat, 22 Jul 2000 10:40:59 -0700 (Pacific Daylight Time) Received: by INET-IMC-02 with Internet Mail Service (5.5.2651.58) id ; Sat, 22 Jul 2000 09:46:49 -0700 Message-ID: From: "Douglas Miles (Volt Computer)" To: "'Jason Che-han Yip'" , prolog@swi.psy.uva.nl Subject: RE: Modifying consulted rules Date: Sat, 22 Jul 2000 09:47:02 -0700 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2651.58) Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01BFF3FC.761132D0" This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01BFF3FC.761132D0 Content-Type: text/plain; charset="ISO-8859-1" 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:yip@ee.ualberta.ca] 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 Miles (Volt Computer) To: 'Jason Che-han Yip' ; prolog@swi.psy.uva.nl 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 ','(_,_). ------_=_NextPart_001_01BFF3FC.761132D0 Content-Type: text/html; charset="ISO-8859-1"
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:yip@ee.ualberta.ca]
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 -----
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  ','(_,_).
------_=_NextPart_001_01BFF3FC.761132D0--