Subject: Re: Modules

From: Lalit Jain <[email-masked]>
Date: Mon, 12 Jun 2000 11:38:28 -0700 (PDT)

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.
> 
>