Fri 06 May 2011 08:02:49 AM UTC, comment #6:
The bug in your code is that you are not doing:
environment.runInitialization(interpreter);
after running ensureLoaded. If you do this then your code will execute as expected.
(the code in question was provided via separate email and is:
Environment environment;
Interpreter interpreter;
environment = new
Environment(); environment.ensureLoaded(AtomTerm.get("src/brain/"+files[i]+""));
interpreter = environment.createInterpreter();
Term[] args = {new IntegerTerm(10)} ;
CompoundTerm goalTerm = new CompoundTerm(AtomTerm.get("test"), args);
Goal goal = interpreter.prepareGoal(goalTerm);
interpreter.execute(goal);
|
Thu 05 May 2011 04:43:04 PM UTC, comment #5:
ok, now I explain my problem.
if I paste this on Gnu Prolog shell :
asserta(iola(10)),iola(Z),retract(iola(_)),iola(Q),write(Q).
Prolog say no, and it's correct because the retract remove all iola predicates, also iola(Z); so iola(Q) fails.
If I do this from Java code, I get 10, and this because between iola's asserta and his retract I call iola(Z).
The complete java code is:
Term[] args = new IntegerTerm(10)} ;
CompoundTerm goalTerm = new CompoundTerm(AtomTerm.get("test"), args);
Goal goal = interpreter.prepareGoal(goalTerm);
interpreter.execute(goal);
and test is:
test(X) :- asserta(iola(10)),iola(Z),retract(iola(_)),iola(Q),write(Q).
What's wrong in my method?
|
Mon 28 Feb 2011 09:31:13 AM UTC, comment #3:
assertz(res(100)),writeRes,retract(res(_)),assertz(res(200)),res(X),write(X).
writeRes :- res(X), write(X).
|
Tue 22 Feb 2011 05:45:06 PM UTC, comment #1:
Bugs like this should have been fixed in 2.6 so I am concerned that it appears that they are not.
I tried
testassertz :- assertz(res(a)), retract(res(_)), assertz(res(b)), listing(res), res(Z), write(Z).
At the bottom of your attached pana.txt and ran it using GoalRunner but I got:
res(b) :- true.
b
Which is the expected output. Please could you give the exact sequence of instructions which causes this bug to manifest itself.
Thank you,
Daniel
|
Mon 21 Feb 2011 05:25:13 PM UTC, original submission:
Hello, i found a BUG using gnuprologjava 2.6.
I have a rule that assert a fact names res(X); later I retract it and assert new one(Y is X*2,assertz(res(Y))).
When I write "listing(res)" I have the correct value of res (that is X*2), but if I do res(Z),write(Z) i have the old value of res, X and not Y.
|