|Did you know ...||Search Documentation:|
|Loading Prolog files|
The WASM build ships with the Prolog library and thus Prolog
libraries can be loaded as normal using use_module/1,
etc., for example, we can include the
lists library using
this directive. Note that the normal autoloading of library
code works in the WASM version.
When Prolog is in asynchronous mode, i.e., called through
we can also load code from a URL. For example, we can load the
demo program directly from
continues the quoted atom from the next line after removing leading
?- consult('https://raw.githubusercontent.com/JanWielemaker/\c chat80/master/prolog/chat80.pl').
Larger files can be loaded as
.qlf files. See section
Notably we can create a single qlf file from an application using the
option. Below we create a
.qlf file from CHAT80.
chat80.qlf can be loaded from a URL using consult/1
?- qcompile('chat80.pl', [include(user)]).
from a string, (2) loading from
<script> elements and
(3) loading from URL. Note that all the loading methods return a
that is resolved when loading the data is completed.
/string/2, ... .
text/prolog. The file reference for the loaded script is
/script/Id, where Id is derived from (1) the
idof the script, (2) the
nameof the script or (3) being the nth Prolog script in the document. When resolved, the promise returns an array with the names of the loaded scripts.
library(lists)or a URL. The sources are downloaded and processed sequentially. This uses Prolog.forEach() calling load_files/1. The returned
Promisereturns 1 on success.