Reminds me of a talk in which a colleague reported correlations of correlations. A few years ago. I was wise enough not to attend it, but I guess P was below 0.05
Another advantage of using relation as predicate argument is that it can avoid discontiguous problem.
For example, if you only focus about the first person, you may prefer to write:
% mary's info likes(mary, apple). hates(mary, orange). % peter's info likes(peter, pear). hates(peter, watermelon). % alice's info likes(alice, apple). likes(alice, lemon). hates(alice, banana).
likes(mary, apple). likes(peter, pear). likes(alice, apple). likes(alice, lemon). hates(alice, banana). hates(peter, watermelon). hates(mary, orange).
but SWI-Prolog will complain
Clauses of likes/2 are not together in the source-file... Use :- discontiguous likes/2. to suppress this message`.
There is no problem if you write:
% mary's info x(mary, likes, apple). x(mary, hates, orange). % peter's info x(peter, likes, pear). x(peter, hates, watermelon). % alice's info x(alice, likes, apple). x(alice, likes, lemon). x(alice, hates, banana).
Here the relations are something like “fields” in OOP.
I’m not sure if this pattern (i.e. using relations to simulate OOP) has been widely used in LP community?
IMO this one is not a good enough reason to reify the relation that way, SWI-Prolog warns about discontiguous predicate definitions because by convention clauses of a single predicate are written contiguously and discontiguous definitions are often the result of a programmer error. Hence the compiler “complains”.
If don’t want this convention to apply to one predicate or another, why not just use the
:- discontiguous directive as suggested?