The new predicate current_module/1 allowed me to
add a couple of test cases, that already test a
little bit name spaces.
A bigger challenge is testing the dynamics of
an interactive module system. Basic expectation here
could be the following: It shouldn't matter in
which order clauses are input, either clauses
from unnamed modules or clauses from named modules.
Sounds good? Very difficult to implement.
Here is an example with only unnamed modules, to
show what I mean:
Welcome to SWI-Prolog (threaded, 64 bits, version 7.7.14)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
?- ['swiunnamed.p'].
?- test.
ERROR: Undefined procedure: foo/0
?- [user].
foo :- write(hello), nl.
?- test.
hello
So basically I had an interlevaing failed call to test/0,
and added foo/0 later. Does the same also work with
a named module. So far no:
Welcome to SWI-Prolog (threaded, 64 bits, version 7.7.14)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
?- ['swinamed.p'].
?- test.
ERROR: Undefined procedure: swinamed:foo/0
?- [user].
foo :- write(hello), nl.
?- test.
ERROR: Undefined procedure: swinamed:foo/0
How can visual code IDE delivered with such a behaviour?
Here is the same test with Jekejeke Prolog. There is even a
help message, but the message is slightly off, it shows foo/0
qualifed, and it doesn't help it, since the named module was
anyway not notified of the new foo/0 predicate, and couldn't
change its lookup:
However, there are definitions for:
swinamed:foo/0
I am retesting the module system truth maintenance, because of
my intro of hierarchical knowledge bases. So I have to look
at everything again, to see whether it still works.
Here is what currently works, only showing the harder
named case:
Jekejeke Prolog 2, Runtime Library 1.2.7
(c) 1985-2018, XLOG Technologies GmbH, Switzerland
?- sys_add_path('nested').
Yes
?- ensure_loaded('nested/jeknamed.p').
% 1 consults and 0 unloads in 0 ms.
Yes
?- test.
Error: Undefined predicate foo/0.
foo/0
test/0
?- [user].
foo :- write(hello), nl.
Yes
?- test.
hello
Yes
I guess the problem is the interleaving call to test/0.
So this high interactivity might put a great challenge to
a Prolog system. The call test/0 causes possibly
a premature clause compilation, which is not undone
later on. It could be also only an inline call cache,
which is not invalidated...
For code and screenshots see here:
https://gist.github.com/jburse/baa1a055a1e2fb28f4defa539b787d1c#file-swinamed-p