Subject: Re: Why? What to do here?

From: "Richard A. O'Keefe" <[email-masked]>
Date: Tue, 22 Aug 2000 11:01:01 +1200 (NZST)

>For SWI-Prolog Version 3.3.8
	>1 ?- clause( 2<3, P).
	>ERROR: No permission to access private_procedure `(<)/2'
	>2 ?-
	>
	>What is happening?

What's happening is that the implementation of built-in predicates is
highly implementation-dependent.  Some Prologs might have "real" clauses
for them, calling primitive operations, such as
	X < Y :- 28.
Some Prologs might have "fake" clauses for them, such as
	X < Y :- X < Y.
(which would actually have worked in Quintus Prolog, although we didn't do
it that way).  Other Prologs again might have calls to foreign code,
handled just like other calls to foreign code.  And yet other Prologs might
not have anything that looks even remotely like a clause, just special code
in the compiler and different special code in the interpreter.

Even amongst DEC-10 prolog, C Prolog, and PDP-11 Prolog, written by members
of the same group at about the same time, there were such differences.

The result is that there is NOTHING a sensible Prolog program can usefully
do by trying to look at the implementation of a built-in predicate.  I'm
the one who when at Quintus decided to use 'permission error'; that has
always meant "the thing you are asking about (notionally) exists but you
aren't allowed to look at it".  In this case, "because you would not get
a meaningful answer".

A hack that would have worked for meta-circular interpreters would have
been to define
	clause(p(X1,...,Xn), true) :- p(X1,...,Xn).
for built-in predicates, but that would have been a very bad idea for
other uses of clause/2.

In retrospect, a really good hack would have been something like
	clause(p(X1,...,Xn), built_in(p(X1,...,Xn)).
for built-in predicates, but that's the path not thought of, let alone
chosen.