Two gotchas: initialize, and -f flag

Doing some refactoring, I discovered that the goal


succeeds for any <module>, regardless of whether the module exists or not, without any warning or error message. This can be, of course, very confusing in the presence of typos or when renaming modules.

A similar issue is that swipl -f <filename> does not report an error if <filename> does not exist.

That applies for any goal that is built-in or can be lazily loaded. The good old Quintus module system defines that a qualified goal silently creates the addressed module if it does not exist.

The module system is not designed with qualified goals in mind, except for debugging and some special use cases. Instead, you import the predicates you need into the module you are working in and call them without qualification. If there is a name conflict, Quintus required using use_module/2, not importing the conflict from one source and using explicit qualification for that call. SWI-Prolog and a few more allow for as to import a predicate under a different name to avoid the conflict.

:- use_module(myfile, [p/1 as my_p]).

I’m not sure this is ideal. It surely is not now most modern languages handle modules.

-f specifies the name of the user initialization file. If you want to run a file, simply use

swipl filename

Thanks for the clarifications — will avoid qualified goals!