Subject: Re: Static and Dynamic Prolog clauses

From: "Richard A. O'Keefe" <[email-masked]>
Date: Tue, 16 May 2000 13:12:00 +1200 (NZST)

Darryl Davis <[email-masked]> wrote
	 In some code from another academic institution (which runs under
		Quintus) there are static definitions for a relation
		and dynamic additions through the use of assert at run-time.
	 v3.3.6 complains about this.
	
So does Quintus Prolog.
From the Quintus Prolog 3.0 manual, section F.15-2-1: assert(+Clause)

	If there is a static definition for the specified predicate,
	then assert/1 fails, an error message is sent to the standard
	error stream, and the system enters the debugger in trace mode.

From section F.15-4: clause(+Head, ?Body)

	If the principal functor of Head is (sic.) a static predicate,
	clause/2 fails, an error message is sent ot the standard error
	stream, and the system enters the debugger in trace mode.
	
	 E.g.
	    ?- listing(next_episode).
	
	    next_episode(A, B) :-
	        clause(next_episode(A, B), !), !.
	    next_episode(A, B) :-
	        following(A, B).
	
	    Yes
	    ?- assert(next_episode(t5,t4)).
	    ERROR: No permission to modify static_procedure `next_episode/2'
	
As well it should!

	Any suggestions as to work-around this.

(A) Ask the authors to fix their code.
(B) Declare the predicate :-dynamic.
(C) Split the predicate into two predicates:  a static part and a
    dynamic part.  Change all the asserts to modify the dynamic part.

	It seems like a reasonable thing to do in prolog
	
Not really, no.  There are good reasons for distinguishing dynamic from
static code.  Trying to mix them in one predicate is asking for trouble.