Subject: Re: Static and Dynamic Prolog clauses

From: Jan Wielemaker <[email-masked]>
Date: Tue, 16 May 2000 10:36:36 +0200

On Mon, 15 May 2000, Darryl Davis wrote:
>Hi
>
> I have a slight problem with SWI-v3.3.6 and the use of 'assert'.
> 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.
>
> 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'
>
>Any suggestions as to work-around this. It seems like a reasonable 
>thing to do in prolog

No, it's not.  This holds for Quintus too, unless the code was compiled
with the `all-dynamic' option.  Simply add

	:- dynamic
		next_episode/2.

before the definition of next_episode/2.  (actually after works too,
but that is not according to the standard and might change someday).

	Regards --- Jan

P.s.	These two clauses look pretty suspicious ...