From jan@swi.psy.uva.nl  Fri Jul 21 09:37:42 2000
Received: from gollem.swi.psy.uva.nl (root@gollem [145.18.152.30])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id JAA25198;
	Fri, 21 Jul 2000 09:37:42 +0200 (MET DST)
Received: (from jan@localhost)
	by gollem.swi.psy.uva.nl (8.9.3/8.9.3/SuSE Linux 8.9.3-0.1) id JAA11200;
	Fri, 21 Jul 2000 09:37:50 +0200
Date: Fri, 21 Jul 2000 09:37:50 +0200
Message-Id: <200007210737.JAA11200@gollem.swi.psy.uva.nl>
From: Jan Wielemaker <jan@swi.psy.uva.nl>
Subject: Re: Resetting
To: "Jason Che-han Yip" <yip@ee.ualberta.ca>, <prolog@swi.psy.uva.nl>
In-Reply-To: Jason Che-han Yip's message of Thu, 20 Jul 2000 18:48:01 -0600
Phone: +31 - 20 - 525 6121

> 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

