Open pmoura opened 4 years ago
Some details of what is happening (in Ciao's module system):
current_module/1
succeeds for loaded modules, but not necessarily the visible ones ...predicate_property/3
is restricted to the predicates and modules visible in the caller module (so that we can process the info statically when possible)If Ciao semantics are too restrictive we can relax them, at least for code using the strict ISO compatibility mode.
Is there a test in Logtalk test suite that reflects the expected behavior? Thanks!
When calling a Prolog module predicate from within a Logtalk object (or category), the compiler must be able to access key predicate properties such as a meta-predicate template so that the call is compiled correctly. For reliability, this require that the module is already loaded. An example is:
https://github.com/LogtalkDotOrg/logtalk3/tree/master/examples/symbiosis
If I modify this example to run load on Ciao, by using its hiordlib
library, I get:
?- {loader}.
Note: module hiordlib already in executable, just made visible
% [ /Users/pmoura/logtalk/library/types/comparingp.lgt loaded ]
% [ /Users/pmoura/logtalk/library/types/termp.lgt loaded ]
% [ /Users/pmoura/logtalk/library/types/term.lgt loaded ]
% [ /Users/pmoura/logtalk/library/types/atomic.lgt loaded ]
% [ /Users/pmoura/logtalk/library/types/atom.lgt loaded ]
% [ /Users/pmoura/logtalk/library/types/number.lgt loaded ]
% [ /Users/pmoura/logtalk/library/types/float.lgt loaded ]
% [ /Users/pmoura/logtalk/library/types/integer.lgt loaded ]
% [ /Users/pmoura/logtalk/library/types/compound.lgt loaded ]
% [ /Users/pmoura/logtalk/library/types/listp.lgt loaded ]
% [ /Users/pmoura/logtalk/library/types/list.lgt loaded ]
% [ /Users/pmoura/logtalk/library/types/type.lgt loaded ]
% [ /Users/pmoura/logtalk/library/basic_types/loader.lgt loaded ]
ERROR: Bad module qualification of maplist/2, module user(/opt/local/share/logtalk/adapters/ciao) does not import the predicate from module hiordlib
ERROR: Bad module qualification of maplist/3, module user(/opt/local/share/logtalk/adapters/ciao) does not import the predicate from module hiordlib
ERROR: Bad module qualification of maplist/3, module user(/opt/local/share/logtalk/adapters/ciao) does not import the predicate from module hiordlib
ERROR: Bad module qualification of maplist/3, module user(/opt/local/share/logtalk/adapters/ciao) does not import the predicate from module hiordlib
ERROR: Bad module qualification of maplist/3, module user(/opt/local/share/logtalk/adapters/ciao) does not import the predicate from module hiordlib
ERROR: Bad module qualification of maplist/2, module user(/opt/local/share/logtalk/adapters/ciao) does not import the predicate from module hiordlib
ERROR: Bad module qualification of maplist/3, module user(/opt/local/share/logtalk/adapters/ciao) does not import the predicate from module hiordlib
{Compiling /Users/pmoura/Documents/Logtalk/logtalk3/examples/symbiosis/.lgt_tmp/symbiosis_2978548357_45120_lgt.pl
ERROR: (lns 21-21) Bad module qualification of maplist/2, predicate not imported from module hiordlib
ERROR: (lns 22-22) Bad module qualification of maplist/3, predicate not imported from module hiordlib
ERROR: (lns 24-24) Bad module qualification of maplist/3, predicate not imported from module hiordlib
ERROR: (lns 25-25) Bad module qualification of maplist/3, predicate not imported from module hiordlib
ERROR: (lns 26-26) Bad module qualification of maplist/3, predicate not imported from module hiordlib
ERROR: (lns 28-28) Bad module qualification of maplist/2, predicate not imported from module hiordlib
ERROR: (lns 29-29) Bad module qualification of maplist/3, predicate not imported from module hiordlib
ERROR: Aborted module compilation
}
% [ /Users/pmoura/Documents/Logtalk/logtalk3/examples/symbiosis/symbiosis.lgt loaded ]
% [ /Users/pmoura/Documents/Logtalk/logtalk3/examples/symbiosis/loader.lgt loaded ]
% (0 warnings)
The loader.lgt
file includes the directive:
:- use_module(library(hiordlib), []).
This directive loads the module into user
. But despite that we get the errors above on explicitly-qualified calls to the hiordlib
exported predicates (from code that's also being loaded into user
). Same errors if we use instead a use_module/1
directive.
With a loaded module, e.g.
is not possible to query the properties of predicates exported by the module: