Doc needs help
You can actually also pass a series of files (is this inofficial? The argument just says
:File. Note that the mode indicator
: indicates a meta-predicate argument, i.e.
File would be a goal. That makes no sense,
File is just a file.
If you use
The code entered will be added to the special
user module. See: Reserved Modules and using the‘user' module
Consult always succeeds
Even if the file to load has errors- It is then loaded partly.
For this file:
child_of(joe, ralf). child_of(mary, joe child_of(steve, joe).
?- [test]. ERROR: /home/paquette/java/test.pl:2:20: Syntax error: Operator expected true. ?- child_of(X,Y). X = joe, Y = ralf.
What if I want to transactionally succeed/fail when loading a file and know whether the loading succeeded? 🤔
Module files aren't special
Reload loaded files that have changed on-disk
Use make/0 to reconsult changed files.
If there are files "roo", "foo", "
foo.pl" and "
also load "
Loading file "foo" is not possible, but
still loads "roo"
It is only the suffix ".pl" which is processed this way. If the suffix is not ".pl", you cannot leave the suffix out in the argument to consult. This is relevant for files containing plunit unit test code, which are supposed to end in '.plt'.
Loading unit test files
At plunit, we read:
"Test-units can be embedded in normal Prolog source-files. Alternatively, tests for a source-file can be placed in another file alongside the file to be tested. Test files use the extension .plt. The predicate load_test_files/1 can load all files that are related to source-files loaded into the current project."
There is no direct support for files ending in .plt via [consult], you have to write
On the other hand, once you have read a `.pl` file then you can use load_test_files/1:
will read the files names the same way only with `.plt` extension.
After that, you can run the test code in the .plt files with
Encoding of source files
In particular, this source file should be loadable without problems:
citation :- писатель(1,Author), цитирование(1,Citation), format("Author: ~s~nCitation: ~s~n",[Author,Citation]). % Facts! писатель(1,"Р.П.Уоррен"). цитирование(1,"Ты должна сделать добро из зла, потому что его больше не из чего сделать.").