logtalk_load(File, Flags) logtalk_load(Files, Flags)
Compiles to disk and then loads to memory a source file or a list
of source files using a list of compiler flags. The Logtalk source file name
extension (by default,
.lgt) can be omitted. Source file paths can be
absolute, relative to the current directory, or use library notation.
Compiler flags are represented as flag(value). This predicate can also be
used to compile Prolog source files as Logtalk source code. When no recognized
Logtalk or Prolog extension is specified, the compiler tries first to append a
Logtalk source file extension and then a Prolog source file extension. If that
fails, the compiler tries to use the file name as-is. For a description of the
available compiler flags, please see the Compiler flags section in
the User Manual. The recognized Logtalk and Prolog file extensions are defined
in the backend adapter files. The recognized Logtalk
and Prolog file extensions are defined in the
backend adapter files.
When this predicate is called from the top-level interpreter, relative source file paths are resolved using the current working directory. When the calls are made from a source file, relative source file paths are resolved by default using the source file directory (unless a relative_to flag is passed).
Note that only the errors related to problems in the predicate argument are listed below. This predicate fails on the first error found during compilation of a source file. In this case, no contents of the source file are loaded.
The compiler flags specified in the second argument only apply to the files listed in the first argument and not to any files that those files may load or compile. Notably, if you are loading a loader file, the flags only apply to the loader file itself and not to the files loaded by it.
Modes and number of proofs¶
logtalk_load(@source_file_name, @list(compiler_flag)) - zero_or_one logtalk_load(@list(source_file_name), @list(compiler_flag)) - zero_or_one
Fileis a variable:
Filesis a variable or a list with an element which is a variable:
File, or an element
Fileslist, is neither a variable nor a source file name:
File, or an element
Fileslist, uses library notation but the library does not exist:
Fileor an element
Fileslist, does not exist:
Flagsis a variable or a list with an element which is a variable:
Flagsis neither a variable nor a proper list:
Flagslist is not a valid compiler flag:
Flagslist defines a value for a read-only compiler flag:
permission_error(modify, flag, Flag)
Flagslist defines an invalid value for a flag:
% compile and load the "list" source file in the % current directory using default compiler flags: | ?- logtalk_load(list, ). % compile and load the "tree" source file in the "types" % library directory with the source_data flag turned on: | ?- logtalk_load(types(tree)). % compile and load the "file_system" source file in the % current directory with portability warnings suppressed: | ?- logtalk_load(file_system, [portability(silent)]).