I feel I have understood finally about module transparency, only one hour ago by practicing as following log. I am glad if it clarifies some confusion on module transparency for some prologers like me.
In the log below,
-
zdd/1
is a meta predicate defined in modulezmod
. -
udg_path_count/3
is defined in modulefrtvec
, which is loaded in modulezmod.
?- context_module(X).
X = zmod.
?- zdd udg_path_count(a-b, [a-b,b-c,a-c], C).
ERROR: Unknown procedure: zmod:udg_path_count/3
<snip>
?- frtvec:(zdd udg_path_count(a-b, [a-b,b-c,a-c], C)).
C = 2. % as expected.
?- context_module(M).
M = zmod.
?- module(frtvec). % change to module `frtvec`
true.
?- context_module(M).
M = frtvec.
?- zdd udg_path_count(a-b, [a-b,b-c,a-c], C).
C = 2. % as expected without module prefix 'frtvec'.
What was that confused me on module transparency ? It is
a “secret”, which should be cleared only through practice.
EDIT Sorry. I forgot to export udg_path_count/3
. With exporting the predicate, every query in the log turned out “YES” without error.