Ignore this – I figured out my mistake.
I’m working on protobufs.pl and hacking test_cover.pl
to make sure my test cases are sufficient. None of the code directly uses library(yall), but apparently it’s getting imported indirectly.
Questions:
- How do I figure out what is importing library(yall)?
- How do I turn off the weird behavior of yall’s (/)/2 predicate?
Here are details from a session, with some comments interspersed.
$ /usr/bin/swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 8.3.26)
?- [library(protobufs)].
true.
The code for write_type/5
consists of 6 facts and is here: contrib-protobufs/protobufs.pl at 42ff818ff8603b129daea44ff986de6f97ede219 · SWI-Prolog/contrib-protobufs · GitHub … I confirm this by:
?- forall(protobufs:wire_type(T,V), writeln(wiretype(T,V))).
wiretype(varint,0)
wiretype(fixed64,1)
wiretype(length_delimited,2)
wiretype(start_group,3)
wiretype(end_group,4)
wiretype(fixed32,5)
true.
So, there should be 6 results from clause/3 … but no:
?- clause(protobufs:wire_type/2, Body, Ref).
false.
So, I try to find the predicate properties. Note the following strange values:
imported_from(yall)
file(/usr/lib/swi-prolog/library/yall.pl)
number_of_clauses(1)
– should be 6.
line_count(275)
– discussed below
?- forall(predicate_property(protobufs:wire_type/2, P), writeln(P)).
interpreted
visible
static
imported_from(yall)
transparent
meta_predicate? / 0
file(/usr/lib/swi-prolog/library/yall.pl)
line_count(275)
number_of_clauses(1)
number_of_rules(1)
last_modified_generation(5556)
defined
size(384)
true.
And now clause/3 succeeds – although with a strange Body
:
?- clause(protobufs:wire_type/2, Body, Ref).
Body = (lambda_free(wire_type), copy_term_nat(wire_type+2, wire_type+_548), call(_548)),
Ref = <clause>(0x560e3a6f4720).
As for line_count(275)
: it corresponds to this: swipl-devel/yall.pl at 5772c803985cb8f88b0f96052abf8c939f8b8c23 · SWI-Prolog/swipl-devel · GitHub
'/'(Free, Lambda) :-
lambda_free(Free),
copy_term_nat(Free+Lambda, Free+LambdaCopy),
call(LambdaCopy).
which is exported by library(yall).