Subject: Re: Why? What to do here?

From: Jan Wielemaker <[email-masked]>
Date: Mon, 21 Aug 2000 10:01:17 +0200

On Sun, 20 Aug 2000, fred wrote:
>Hi,
>
>Why is this happening? And what can be done to
>stop it happening?
>
>For SWI-Prolog Version 3.1.0
>?- clause( 2<3, P).
>
>No
>?-
>
>OK. Now try the same thing again
>For SWI-Prolog Version 3.3.8
>1 ?- clause( 2<3, P).
>ERROR: No permission to access private_procedure `(<)/2'
>2 ?-
>
>What is happening? Where is the
>documentation for 'private_procedure'?
>Where is any documentation relating to
>this behaviour?
>Can this unwanted behaviour be switched
>off? If so, how?
>
>This behaviour is killing interpreters written
>for 3.1.0!

It is ISO (or, at least my understanding thereof :-).
It is also not uncommon:

gollem (jan) 1_> sicstus
SICStus 3.7.1 (Linux-2.0.34-i686): Mon Oct 05 20:02:29 CEST 1998
Licensed to swi.psy.uva.nl
{consulting /swi40/jan/.sicstusrc...}
{/swi40/jan/.sicstusrc consulted, 0 msec 208 bytes}
| ?- clause( 2<3, P).
{PERMISSION ERROR: clause(user:(2<3),_42) - cannot access static user: < /2}
| ?- 

So, a correct interpreter in ISO looks like this:

solve((A,B)) :- !,
	solve(A),
	solve(B).
...
solve(Goal) :-
	catch(clause(Goal, Body), _, fail), !,
	solve(Body).
solve(Builtin) :-
	call(Builtin).

You can also use

...
solve(Builtin) :-
	predicate_property(Builtin, built_in), !,
	call(Builtin).
solve(Goal) :-
	clause(Goal, Body),
	solve(Body).

which I think is the most clean solution (nicely giving an
exception if an undefined predicate is encountered too :-)

	Regards --- Jan