I have pushed an update to #wasm and updated the wiki page. There are two big developments:
- Call between Prolog and JavaScript and JavaScript and Prolog are getting close to their final version.
- Calls from Prolog to JavaScript can represent DOM elements as Prolog blobs. The DOM elements known to Prolog are subject to Prolog garbage collection
For example, we can how define a Prolog predicate to add a paragraph to the shell output window:
add_par(Text) :-
Out := document.getElementById("output"),
More := document.getElementById("more"),
Par := document.createElement("p"),
Par.textContent := Text,
_ := Out.insertBefore(Par, More).
After which we can call
?- add_par("Hello world!").
We can also call the other way around nicely, for example writing all the results of p/1
:
for(const r of Prolog.query("p(X)")) {
console.log(r.X);
}