scryer-prolog
scryer-prolog copied to clipboard
Problem with clause
This is taken from Logtalk...
:- initialization(main).
:- dynamic(legs/2).
legs(A, 7) :- A, call(A).
main :-
clause(legs(C,7), Body),
Body == (call(C),call(C)),
write(succeeded), nl,
halt.
main :-
write(failed), nl,
halt.
This should succeed, obviously, as do swipl & gprolog.
Currently,
?- clause(legs(C,7), Body).
Body = (C,call(C)). % unexpected
That is, there is no term-to-body conversion (7.6.2) which also interferes with the way how cut is handled.
See also
call(',', C=!, (X=1,C;X=2)).
$ ~/.cargo/bin/scryer-prolog ?- call(',', C=!, (X=1,C;X=2)). C = !, X = 1. ?-
which should generate two solutions as the call to naked variable C is equivalent to call(C) and so the cut should be localized within that call.
$ gprolog | ?- call(',', C=!, (X=1,C;X=2)). C = ! X = 1 ? ; C = ! X = 2 (1 ms) yes | ?-
Note: the outer call is just fluff here and comes from a Logtalk example.
Note: the outer call is just fluff here and comes from a Logtalk example.
The original test is indeed a test for the call/N
predicate.
This now fails because of the meta-predicate expansions:
?- clause(legs(C,7),Body), Body==(call(user:C),call(user:C)).
Body = (call(user:C),call(user:C)).
?- clause(legs(C,7),Body), Body==(call(C),call(C)).
false.
I can't speak for GNU Prolog but I believe SWI uses an atom-based module system, not a predicate-based one.
I can't speak for GNU Prolog but I believe SWI uses an atom-based module system, not a predicate-based one.
GNU Prolog doesn't provide a module system. SWI-Prolog module system is (like almost all systems) predicate-based. XSB is an example of an atom-based system.
XSB is functor based. SWI is predicate based but not exactly like SICStus. It still can transmit module information in a module transparent manner. Also it does a lot of implicit :
-dereferencing.
With 40d3345cd538b826bc91f3592562c4a32f69415e:
$ scryer-prolog
?- [user].
:- initialization(main).
:- dynamic(legs/2).
legs(A, 7) :- A, call(A).
main :-
clause(legs(C,7), Body),
Body == (call(C),call(C)),
write(succeeded), nl,
halt.
main :-
write(failed), nl,
halt.
succeeded