Thank you, again Jan. You’ve helped me with this before. I’m sorry that I keep coming back to it.
This is indeed what I’ve done up to now. I create the new module (the one with the database) like this:
%! load_experiment_file(+Filename) is det.
%
% Load a new experiment file, unloading the old one.
%
load_experiment_file(F):-
load_files(F, [module(experiment_file)
,redefine_module(true)
]).
As to the candidate rules (what we call the “hypothesis”, i.e. a logic program that we want the system to learn from examples and background knowledge in the experiment_file module) I generally don’t need to keep it separated so I just assert it into the experiment_file module where it can easily find the “databas” (i.e. the examples and background knowledge) so that’s not a problem.
So what’s the problem? I really need to get you a proper bug report, if this is indeed a bug, but here’s what I understand. Say I have a dataset file (the “database”) called family_relations.pl. To load it, I’d pass its (expanded) path to load_experiment_file/1. No problem with that, I can use the data in family_relations.pl and learn a hypothesis and so on.
Trouble begins when I edit family_relations.pl and then call make/0 to reload everything. There is a directive in my code that calls load_experiment_file/1 so the edited family_relations.pl gets re-loaded. I want that, because I want the changes I made to it to be loaded in memory. But if I do this, at some point down the line I invariably get a permission error (along the lines of "
ERROR: import/1: No permission to import … already imported from …"). Sorry I don’t have the exact error, I posted about it here previously (Re-defining a predicate in a new module file, vs. in a traditional file). In fact, I set everything up with the redefine_module options after your kind advice in that thread.
I think what happens at that point is that I have two Prolog modules both exporting the same predicates, which is to say, the predicates defined in family_relations.pl. There’s a copy of those predicates now exported from both the experiment_file and family_relations modules. That happens only if I edit, save, and reload the family_relations.pl module, so that’s what’s causing the trouble.
I’ve been working around this by starting two separate SWI-Prolog sessions, one where I run my system, and one where I edit the experiment files. The one that is running my system is without the IDE so I can restart often without messing up my workflow. So this is not blocking me, but I’m worried that any user that picks up my system will stumble upon the error, swear at me, and never use my system again.
I don’t even know if this is a bug. I think it’s kind of expected to happen that way, I just haven’t worked out a way to avoid it in the code yet.