Clause references in Prolog have a little untouched existence.
There are seldom in the spotlight. One could take SWI-Prolog
as a template, but will probably run into ideas of built-ins supporting
multiple modes. So whats the result of this test case:
:- dynamic(foo/0).
foo.
foo:-bar.
?- clause(foo, X, R), clause(H, B, R).
In my system I have now a library(kbrefs), with strictly
only (+,-,-) mode, there is a built-in compiled/3 with (+,-,-) now
having a clause reference instead a clause head as input,
the less confusing version of instance/2 in SWI. There is
no standard or PIP for clause references, and I noticed
the SWI API could have some things missing, especially if
one wants to implemented embedded implication as:
:- ensure_loaded(library(edge/kbrefs)).
:- op(1200, xfx, -:).
% -:(+Clause, +Goal)
(C -: G) :-
compile(C, R),
(recordz(R); erase(R), fail),
G,
(erase(R); recordz(R), fail).
compile/2 and recordz/1 are missing, but there are useful,
since the clause will be only compiled once, while an assertz/2
solution would compile a clause multiple time. I am not saying
I am inplementing a lambda Prolog. The semantics is still that
the clause payload gets automatically universally quantified.
For a lambda Prolog one needs some quantifier marks to
distinguish between variables that get universally quantified,
and those variables that are not quantified, i.e. that are shared
with the context of the goal call by the new built-in (-:)/2.