Re: modules

From: Joachim Schimpf <j.schimpf_at_icparc.ic.ac.uk>
Date: Tue 19 Sep 2000 05:47:15 PM GMT
Message-ID: <39C7A6A3.96089728@icparc.ic.ac.uk>
Hi,

it is a basic rule of the module system is that once the
visibility of a predicate is established, it cannot be changed.


> [eclipse 1]: use_module(m1).

visibility of p not yet fixed, but it CAN be taken from m1.


> [eclipse 2]: p.
> m1

first reference/use fixes the visibility: from now on
the p visible in 'eclipse' is the one from 'm1'.


> [eclipse 3]: erase_module(m1).

erasing m1 does not affect this.


> [eclipse 4]: use_module(m2).

since there is already a visible p, the one in m2
is ignored (this could be made to raise a warning,
but most of them would be uninteresting).


> [eclipse 5]: p.
> calling an undefined procedure p in module eclipse

we are calling m1:p which does not exist any more.



> [eclipse 6]: current_predicate(X).
> 
> X = system / 1     More? (;)
> 
> no (more) solution.

current_predicate/1 lists only defined predicates.
But you can call pred/1 to see what's going on:

[eclipse 7]: pred(p/0).
...
declared            on
...
defined             off
...
visibility          imported
...
definition_module   m1
...




> A related behavior is
>
> [eclipse 1]: use_module(m1).
> m1.pl      compiled traceable 60 bytes in 0.00 seconds
> 
> yes.
> [eclipse 2]: erase_module(m1).
> 
> yes.
> [eclipse 3]: use_module(m1).
> not a module in use_module(m1)
> [eclipse 4]:
> 
> Is this also a bug?

That's ok. the information that something is imported from m1
can exist even while m1 does not (yet/anymore/currently) exist.
When you re-create the module later, the dangling import-links
will effectively be reconnected.


> 
> We are trying to use erase_module so that we have a module where we keep
> data. When we erase it we want to reset it completely.

The module _does_ get completely erased.

What does not get erased is information in other modules saying that
they'd like to refer to something in the erased module.

If you data modules all have the same module name and all export the
same predicates, then you are ok: just replace the module with
another one that has the same interface but different content.

If your data modules have different interface and/or names, then
don't create import links, i.e. don't use import/use_module.
Just compile the data module and access its predicates with
qualified calls  ModuleName:Call.

Cheers,
-- 
 Joachim Schimpf              /             phone: +44 20 7594 8187
 IC-Parc, Imperial College   /            mailto:J.Schimpf@ic.ac.uk
 London SW7 2AZ, UK         /    http://www.icparc.ic.ac.uk/eclipse
Received on Tue Sep 19 18:47:16 2000

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:08:00 PM GMT GMT