ModuleFile is a module name, a source file name, a library specification (e.g. library(util)) or a list of such items. First, ModuleFile is converted to a file name and that file is loaded, compiled or recompiled as with ensure_loaded/1. Then, a module name is extracted from the base name of ModuleFile (the loading is expected to create that module, i.e. the file is expected to follow the naming convention for module files). That module is then imported as with import/1.
The rules for finding the source file from the ModuleFile specification are the same as for ensure_loaded/1 and compile/1, i.e. object or source file suffixes are appended, and the library path is searched if the name is specified as library(FileName).
Success: :- use_module(library(util)). :- use_module("/usr/local/eclipse/lib/util"). :- use_module(util). :- use_module("util.pl"). Error: :- use_module(M). (Error 4). :- use_module(file(f)). (Error 5).