OK, so here’s my use case. I’m working on this ILP system called Louise. The
datasets to train Louise are organised in “experiment files” that are Prolog
modules with a common public interface exporting four “interface predicates”:
background_knowledge/2
, metarules/2
, positive_example/2
and
negative_example/2
(the last two are generators). Each experiment file may
include background knowledge, metarules and examples for more than one learning
problem.
Which experiment file is currently loaded is controlled with an entry in a
configuration file. In this configuration file there are clauses of the
predicate experiment_file/2
. The first argument is the path to the Prolog
source file holding the experiment file module; and the second argument is the
name of the module. The module name is separate to allow modules with a file
name that doesn’t match their module name, sometimes useful. Here’s an example:
experiment_file('path/to/my/file.pl', module_name).
Now, the way it worked until Swi 8.2.1 was that when I wanted to load a new
training dataset, I would change experiment_file/2
to point to the new file,
then reload the configuration module. That would call a directive :-reload.
at
the end of the configuration module that a) unloaded the previously loaded
experiment file module, b) abolished all its definitions of the four interface
predicates, c) loaded the new module and d) asserted to the dynamic database a
term holding the path and name of the newly loaded experiment file module (so
that reload/0
would know where to find the definitions of the interface
predicate to abolish, upon the next call).
The upshot of all this was that, once reload/0
was done, the definitions of
the four interface predicates in the dynamic database were now the ones in the
experiment file listed in the latest experiment_file/2
term. The definitions
in previous experiment files were abolished. The point was to know which dataset
I was currently training with, so a kind of manual garbage collection if you
will. Unfortunately, this seems to have been a bit of a hack and it stopped
working after 8.2.1. “It stopped working” in the sense that if I performed the
set of steps described above, after the first two or three times, I’d start
seeing errors about redefining a module.
My original hack worked well for my needs, but I haven’t been able to do what I
want as well ever since.
Thank you for your earlier helpful reply and apologies for the confusion!