Changed behaviour of load_files?

For SWI-Prolog version 7.7.17 to 8.1.4-1 on Mac and Windows the call to

?- load_files(file, [module(m),  redefine_module(true)]).

does not load the file as intended into m but apparently into all existing modules (or into ‘user’ from where it gets imported to all other modules).

If I call the predicate twice, like this,

 ?- load_files(file1, [module(m1),  redefine_module(true)]).
 ?- load_files(file2, [module(m2),  redefine_module(true)]).

the contents of ‘file2’ erases the one of file1 EVERYWHERE, including in ‘m2’.

Is this an intentional change? The online documentation still nourishes the hope that ‘file1’ would be loaded to module ‘m1’ and ‘file2’ to ‘m2’ (which is what I actually want to achieve). Any help would be appreciated.

Thanks,
Günter

If the file is a plain Prolog file, a workaround is to use instead:

?- m:load_files(file).

Are file, file1, file2 module files? The docs state that this option is there to overrule the module/2 declaration from the file, not to create one. A quick test indeed confirms this option is only honoured fro module files. AFAIK, little has changed wrt loading files in recent versions.

If you have a non-module file and want to load it into a module simply use

:- load_files(m1:file1).

(or probably more portable ensure_loaded(m1:file1).

I tried both ways. The problem occurs also if there is a module declaration in the file. Then the module declared in the module directive is created as well as the module contained in the module option of the load_files predicate and the clauses are visible in each module.

Might it be a bug related to the size of the file? It contains roughly 119000 facts. However, zipped it is just 575 KB, so I could upload it somewhere or mail it for a test.

Anyway, the trick to delete the module declaration from the file and use

:- load_files(m1:file1).

works. Thanks to both for the quick answers.

Cheers,
Günter

I’d assume only the module declaration and a few facts are enough to reproduce the problem. My simple attempt didn’t.