Dear All,
Jekejeke Prolog features already for a while structured
module names. It also works for dynamic modules. For
example we can do the following on the top-level:
Jekejeke Prolog 2, Runtime Library 1.2.3
(c) 1985-2017, XLOG Technologies GmbH, Switzerland
?- [user].
foo/bar:test :- write(hello), nl.
Yes
?- foo/bar:test.
hello
Yes
Syntactically the extension was very simple. Normally
a qualified call reads as follows:
/* unstructured modules */
call --> callable
| atom : callable.
The syntax has changed as follows:
/* structured modules */
call --> callable
| module : callable.
module --> atom
| package / atom.
package --> atom
| package / atom.
The mapping to the file system is relatively easy,
packages correspond to directories, and modules correspond
to files. A dynamic module is created as a fallback when
the file is not found.
Now I have a problem with the new modules term/unify
and term/verify. They require traditionally a key of
the form of an atom, which will refer to an unstructured
module. And I am running out of name spaces.
For example I have a module
suspend.pl, and in
this module I want to define:
freeze/2
when/2
Traditionally I would be forced to create two
extra modules, and then do the following:
/* unstructured solution */
Module
freeze.pl:
define hooks for put_attr(V, freeze, K)
Module
when.pl:
define hooks for put_attr(V, when, K)
Now on the other hand, if put_attr/3 would accept
structured keys, we could go with the following
solution. Namely we could simply do:
/* structured solution */
Module
suspend.pl:
define hooks for put_attr(V, suspend/freeze, K)
define hooks for put_attr(V, suspend/when, K)
Such structured hooks already work on the top-level,
namely the following works already by the same mechanism
as the initial demo foo/bar:test call works:
?- use_module(library(term/unify)).
% 5 consults and 0 unloads in 96 ms.
Yes
?- [user].
foo/bar:attr_unify_hook(_, T) :- write('T='), write(T), nl.
^
Yes
?- put_attr(X, foo/bar, 3).
put_attr(X, foo/bar, 3)
?- put_attr(X, foo/bar, 3), X=abc.
T=abc
X = abc
So the problem is basically already solved. Except for
a small slight issue. I have currently barred dynamic modules
from inside a Prolog text. Because they are not yet correctly
allocated. Working on it...