From jan@swi.psy.uva.nl  Fri Jun  9 13:51:26 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 NAA26273;
	Fri, 9 Jun 2000 13:51:25 +0200 (MET DST)
Received: from localhost (localhost [[UNIX: localhost]])
	by gollem.swi.psy.uva.nl (8.9.3/8.9.3/SuSE Linux 8.9.3-0.1) id NAA10083;
	Fri, 9 Jun 2000 13:52:04 +0200
From: Jan Wielemaker <jan@swi.psy.uva.nl>
Organization: SWI, University of Amsterdam
To: Lalit Jain <lalit@savvion.com>, prolog@swi.psy.uva.nl
Subject: Re: Modules
Date: Fri, 9 Jun 2000 13:46:54 +0200
X-Mailer: KMail [version 1.0.28]
Content-Type: text/plain
References: <Pine.GSO.4.21.0006081822520.4642-100000@neptune.tdiinc.com>
In-Reply-To: <Pine.GSO.4.21.0006081822520.4642-100000@neptune.tdiinc.com>
MIME-Version: 1.0
Message-Id: <00060913520401.09949@gollem>
Content-Transfer-Encoding: 8bit

On Fri, 09 Jun 2000, Lalit Jain wrote:
>Hi All:
>My question is regarding modules. I have a file containing some
>predicates
>(not belonging to any module).
>Now I load the file under the context of a module, say m1; and i can see
>all the predicates when i do listing.
>Then, I load the same file under the context of another module, say
>m2; again I see all the predicates.
>Now, I switch to module m1, and I don't see any predicates there. Why is
>that so?

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.

To get the same clauses into multiple modules, write a file defining
a module and use use_module/1 to load and import the clauses.

You can also have a look at the ISO include(File), which can appear
as a directive in a file and expands to the terms read from File.

	Regards --- Jan

>I have a file foo as:
>
>foo(1).
>
>Now at the prolog interpreter, i say,
>
>1 ?- module(m1).
>Warning: m1 is not a current module (created)
>
>Yes
>m1: 2 ?- [foo].
>% foo compiled into m1 0.01 sec, 520 bytes
>
>Yes
>m1: 3 ?- listing.
>
>foo(1).
>
>Yes
>m1: 4 ?- module(m2).
>Warning: m2 is not a current module (created)
>
>Yes
>m2: 5 ?- [foo].
>% foo compiled into m2 0.00 sec, 128 bytes
>
>Yes
>m2: 6 ?- listing.
>
>foo(1).
>
>Yes
>m2: 7 ?- module(m1).
>
>Yes
>m1: 8 ?- listing.
>
>Yes
>m1: 9 ?- 
>
>
>Thanks,
>Lalit
>
>
>
>
>
>----------------
>* To UNSUBSCRIBE, please use the HTML form at
>
>    http://www.swi.psy.uva.nl/projects/SWI-Prolog/index.html#mailinglist
>
>or send mail to prolog-request@swi.psy.uva.nl using the Subject: "unsubscribe"
>(without the quotes) and *no* message body.
>
>** An ARCHIVE of this list is maintained at
>
>    http://www.swi.psy.uva.nl/projects/SWI-Prolog/mailinglist/archive/

