Hmmm… In the head of the predicate, mycomp(X,Y) is a Prolog term. In the body, it is a goal that you evaluate (or query…).
This is it:
But now both are “singleton variables” without any further constraints on them, so that will succeed for any Z and any W.
What kind of data encapsulation do you mean? This sounds like a technique, not an aim…
When you say “compound term”, you do realize this is really just a data structure and not a predicate? You can evaluate it as a predicate though, this is what happens if you put it in the place of a goal.
I still have a feeling this is a terminology confusion
EDIT: if you want to pass a predicate to a predicate, then you have define a meta-predicate. There is nothing special about it, really. For example, maplist is a meta-predicate, so you can do something like this:
?- maplist(plus(1), [2,3], Result).
Result = [3, 4].
They are so much different, like day and night…
The first form is using call/1, the second instead is using reflection, and this means that the first one executes the code, while the second one lists (kind of) it.
test_of_type(X, Y, Z):-
of_type(X, test_compound(Y, Z)).
?- test_of_type(a, b, c).
?- test_of_type(a, X, Y).
?- test_of_type(test_compound(X, Y), X, Y).
X = a,
Y = b.
?- test_of_type(test_compound(_, _), X, Y).
X = a,
Y = b.
?- test_of_type(test_compound(z, w), X, Y).