Load the specified Prolog source and/or QOF file(s) into memory, if not already loaded and up to date.


Files file_spec or list of file_spec [MOD]
a file specification or a list of file specifications; a .pl or .qof extension may be omitted in a file specification.


Loads each of the specified files except for files that have previously been loaded and that have not been changed since they were last loaded.

In the case of non-module-files, a file is not considered to have been previously loaded if it was loaded into a different module. For restrictions on non-module QOF-files, and how they can be loaded, see load_files/[1,2]. In this case the file is loaded again and a warning message is printed to let you know that two copies of the file have been loaded (into two different modules). If you want two copies of the file, you can avoid the warning message by changing the ensure_loaded/1 command to a compile/1 command. If you do not want multiple copies of the file, make the file a module-file.

When ensure_loaded/1 is called from an embedded command in a file being compiled by qpc, each specified file is compiled from source into QOF unless there is already a QOF file that is more recent than the source.

When ensure_loaded/1 is called in a runtime system, all predicates will be loaded as dynamic predicates and therefore this code will run slower. The reason for this is that the compiler is not available in runtime systems.

This predicate is defined as:

     ensure_loaded(Files) :-
             load_files(Files, [if(changed),

For further details on loading files, see ref-lod.


M or Files is not ground.
In M or in Files.
A specified file does not exist. If the fileerrors flag is off, the predicate fails instead of raising this exception.
A specified file is protected. If the fileerrors flag is off, the predicate fails instead of raising this exception.

See Also

compile/1, load_files/[1,2].