From lalit@tdiinc.com  Mon Jun 12 20:38:24 2000
Received: from oahu.tdiinc.com (oahu.tdiinc.com [206.40.33.137])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id UAA26861;
	Mon, 12 Jun 2000 20:38:23 +0200 (MET DST)
Received: from neptune.tdiinc.com (neptune.tdiinc.com [10.1.4.46])
	by oahu.tdiinc.com (8.9.3/8.9.3) with ESMTP id LAA24944;
	Mon, 12 Jun 2000 11:39:34 -0700 (PDT)
Received: from localhost (lalit@localhost)
	by neptune.tdiinc.com (8.9.0/8.9.0) with ESMTP id LAA25065;
	Mon, 12 Jun 2000 11:38:28 -0700 (PDT)
X-Authentication-Warning: neptune.tdiinc.com: lalit owned process doing -bs
Date: Mon, 12 Jun 2000 11:38:28 -0700 (PDT)
From: Lalit Jain <lalit@savvion.com>
To: "Richard A. O'Keefe" <ok@atlas.otago.ac.nz>
cc: jan@swi.psy.uva.nl, lalit@savvion.com, prolog@swi.psy.uva.nl
Subject: Re: Modules
In-Reply-To: <200006112233.KAA21927@atlas.otago.ac.nz>
Message-ID: <Pine.GSO.4.21.0006121123150.4642-100000@neptune.tdiinc.com>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII

Hi All:

Jan and Richard, Thanks a bunch for your help!

My intention is to have the same set of predicates loaded into two or more
different modules so that I can treat each module space as a session and
assert different facts and execute different goals in each of them.

For now, looks like the way I can do it is to create a module file for
each one and include my original predicate file in it, such as:

file: m1.pro
:- module(m1, [])
:- include('mypreds.pro').

file m2.pro
:- module(m2, [])
:- include('mypreds.pro').

Because I need to create these modules dynamically at runtime, I will need
to create these files at runtime (I load the engine from C++).

Now when I load these files I have two distinct module spaces with the
same predicates. Also, 'mypreds.pro' has some foreign predicates (loaded
using load_foreign_library) and I realized that I'll need to call install
functions seperately from each module with approprirate predicate names
(such as PL_register_foreign(m1:foo, ..)  from module m1
         PL_register_foreign(m2:foo, ..)  from module m2)

Please let me know if you think there's a better way to do this.

** I have one more question, which is, how can I destroy these modules at 
runtime when I no longer need them ?? ** Is these some predicate to
destroy a module space?

Thanks Again!

Lalit.


On Mon, 12 Jun 2000, Richard A. O'Keefe wrote:

> 	On Fri, 09 Jun 2000, Lalit Jain wrote:
> 	>that so?
> 	
> Jan wrote:
> 	Because the system remembers which clauses come from which file.  If a
> 	file is reloaded, all clauses resulting from the previous load will be
> 	removed.
> 	
> And *that* is because consult(F) = [F] is really reconsult(F) = [-F].
> The original idea in DEC-10 Prolog was that
>  - consult was what you used to load a file in the first time
>  - reconsult was what you used to load a *corrected* file in later times
> Now if you make some corrections, it's obvious that
>  - new predicates should come in
>  - changed versions of old predicates should replace the old versions
> But what about predicates that *used* to be in the old version of the
> file but aren't there any more?  The eventual decision was that when
> you reconsult a file F, that should wipe out _everything_ that came from
> F, and then proceed as if loading F for the first time.
> 
> For various reasons, the two got merged.  So now the effect of consult(F) is
>  - first, abolish all predicates previously defined in F (if any)
>  - then load (new) definitions from F.
> The original version of consult/1 made it easy to have clauses for the
> same predicate in several files at the same time, but then made it very
> hard to fix them.  The merged version made it impossible, so :-multifile
> was added to restore that possibility.
> 
> 

