Dear Greg,
The solution depends on the exact scenario. If there is only one client
module, and it has a fixed name, then doing the client an the search
module mutually dependent with normal use_module declarations will
suffice. I suppose the problem is that the client module name may
change, and possibly that there can be multiple client modules. If
there is only one client module, then declaring
:- multifile successor/2.
both in the client and the search module will do the trick. This is not
correct if there can be multiple client modules, because the successor/2
clauses will got merged. The really nice thing in that case would be to
use Ciao's higher-order capabilities, adding to path/3 a higher-order
argument to hold the predicate to call. As an example, lets suppose the
path/3 code would be as simple as:
path(Start, Start, []).
path(Start, End, [Next|RestPath]) :-
successor(Start, Next),
path(Next, End, RestPath).
The new path/4 code would be:
:- meta_predicate path(_,_,pred(2),_).
path(Start, Start, _Succ, []).
path(Start, End, Succ, [Next|RestPath]) :-
Succ(Start, Next), % equivalent to call(Succ, Start, Next)
path(Next, End, Succ, RestPath).
and in the client, if locally is defined successor/2 (any name
possible), the call to path/4 would be:
... path(E0, Ef, successor, Path) ...
Note that in the coming Ciao version (but not in 1.6), to use higher
order the hiord package is needed, so a declaration as
:- use_package(hiord).
would be needed in the path/4 module source.
Regards,
Daniel Cabeza