I have stupid question about the semantics of module
import statement.
I am trying to compare it with the Java import. But
Java import works compile time. There is no equivalent
during runtime, for example in the reflection library.
At compile time it just allows to drop some package
prefix during resolving of names, maybe can even take
into account overloading.
Now in prolog I wonder whether it could be a run-time
mechanism. Assume that we already have a module meachnism
in place which does not yet have import/export. So maybe
I mave a module list, with a predicate member.
:- module(list)
member(X,[X|_]).
member(X,[_|Y]) :- member(X,Y).
Now I have a module main and want to import the predicate
member from the module list. Since I don't have an import
statement I would simply create a stub as follows:
:- module(main).
:- use_module(list).
member(X,Y) :- list:member(X,Y) % the stub
main :-
member(X,[1,2,3]),
write(X), nl, fail.
Does an import correspond to a stub like above? I image
that this could be compiled relative efficiently. For
example predicate unfolding would eliminate the stub
completely.
Best Regards
The whole think would become a runtime machanism if we
could access modules at runtime and add imports respectively
stubs during runtime. Like a dynamic predicate.
Best Regards