call/2

[email protected]
Newsgroups gmane.comp.gnu.prolog.bugs
Message-ID <[email protected]>
not sure if it's a bug or a feature:

call/2 seems to behave differently depending on the order of
the predicates in the database.  if there are predicates left
not matching the goal, but with the same functor, then call/2
never sets to true its second argument.

--- input file ----------------------------------------------
test(aa, a, 1).
test(aa, a, 2).
test(aa, a, 3).
test(aa, b, 1).
test(aa, b, 2).
test(aa, b, 3).

test_call_1 :- call(test(aa, a, X), Z), write(a: X), nl, Z = true.
test_call_2 :- call(test(aa, b, X), Z), write(b: X), nl, Z = true.
-------------------------------------------------------------

--- run -------------
| ?- test_call_1.
a:1
a:2
a:3

no
| ?- test_call_2.
b:1
b:2
b:3

yes
---------------------

note that this does not happen, i.e., you get a 'yes' with test_call_1
if you use test/2 predicates instead of test/3 ones (and modify
test_call_1 and test_call_2 accordingly...), like this:

	test(a, 1).
	test(a, 2).
	etc.

I mean, I had to put the 'aa' in order to trigger this (bug?).

I have not done further tests:  I'd rather first understand if it's
really a bug;  I am quite new to prolog.

regards,
stefano frabetti


--- info ----------------------------------------------------------
uname -a
Linux embeh.sif.it 2.4.18-SGI_XFS_1.1-2002-07-09 #7 Tue Jul 9 12:48:20 CEST 2002 i686 unknown

gprolog --version
Prolog top-Level (GNU Prolog) 1.2.13
-------------------------------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.