What is the difference between these two goals?
foo(A) :- A, !, fail.
foo(A).
foo(A) :- call(A), !, fail.
foo(A).
They seem to behave identically? What is the purpose of call/1
and is there an example of when it matters?
What is the difference between these two goals?
foo(A) :- A, !, fail.
foo(A).
foo(A) :- call(A), !, fail.
foo(A).
They seem to behave identically? What is the purpose of call/1
and is there an example of when it matters?
There is no difference in the output WAM code generated by those snippets of code, as evidenced by issuing
and checking the generated
wbc
file (wheresnippetN.pl
contains either sample code). So it seems is a programmer's choice which one to use. It might be useful to usecall/1
for portability reasons.Recall however the existence of
call/N
with N > 1 which is useful if you want to call a goal which has arguments.For the curious, this is the generated wam file: predicate(foo/1,1,static,private,monofile,global,2).
The only difference is in the header for the clause which in the other snippet reads: