Subject: Re: Resetting

From: Jan Wielemaker <[email-masked]>
Date: Fri, 21 Jul 2000 09:37:50 +0200

> I'm running JPL with SWI-Prolog and while running some tests, I noticed =
> that the database is not being reset, which makes it difficult to test.  =
> Is there some way to cause SWI-Prolog to reset?  I'm somewhat of a =
> Prolog newbie so I also don't know if there is a particular Prolog =
> predicate that can be used to retract everything.

No, but generally it shouldn't be needed.  If you want several programs
to live next to each other peacefully, use modules.  You can quite
easily (using predicate_property/1 and/or current_predicate) enumerate
the predicates in a module and abolish them to free the storage should
that be necessary.

If the trouble is dynamic `case data', you need to keep track of the
predicates involved and use retractall/1 on each of them to clean
them.

For example:

program_data(foo/1).
program_data(bar/2).

:- program_data(Pred),
   dynamic(Pred),
   fail;true.

clean_db :-
	program_data(Name/Arity),
	functor(Head, Name, Arity),
	retractall(Head),
	fail;true.

If you are playing on Unix, you can also consider using the clib package,
which provides the fork() and exec() primitives that may help you restarting
and/or use a deamon that forks subprocesses to deal with `cases'.

	Regards --- Jan