Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use predicate_property/2 to query module predicate properties #28

Open
pmoura opened this issue Jun 8, 2020 · 2 comments
Open
Labels

Comments

@pmoura
Copy link

pmoura commented Jun 8, 2020

With a loaded module, e.g.

?- current_module(between).

yes

is not possible to query the properties of predicates exported by the module:

?- between:predicate_property(between(_,_,_), P).
ERROR: Bad module qualification of predicate_property/2, module user(/Users/pmoura/ciao/core/library/toplevel/toplevel_scope) does not import the predicate from module between
{ERROR: $bad_qualification$:predicate_property/2 - existence error: procedure:$bad_qualification$:predicate_property/2 does not exist}

aborted
?- predicate_property(between:between(_,_,_), P).
ERROR: Bad module qualification of between/3, module user(/Users/pmoura/ciao/core/library/toplevel/toplevel_scope) does not import the predicate from module between

no
@jfmc jfmc added the iso label Jun 8, 2020
@jfmc
Copy link
Member

jfmc commented Feb 13, 2022

Some details of what is happening (in Ciao's module system):

  • despite 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!

@pmoura
Copy link
Author

pmoura commented Feb 13, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants