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

Dynamic predicates are sometimes confused by unrelated libraries #2232

Closed
triska opened this issue Dec 17, 2023 · 2 comments
Closed

Dynamic predicates are sometimes confused by unrelated libraries #2232

triska opened this issue Dec 17, 2023 · 2 comments

Comments

@triska
Copy link
Contributor

triska commented Dec 17, 2023

To reproduce this issue, please create file.pl comprising:

:- use_module(library(clpz)).

clpz:monotonic.

Consulting this file on the toplevel works exactly as expected:

$ scryer-prolog -f
?- [file].
   true.

When I then keep the process running and change the file to read:

:- use_module(library(lists)).
:- use_module(library(clpz)).
:- use_module(library(dcgs)).

% clpz:monotonic.

i.e., I have added 2 additional libraries, lists and dcgs, respectively before and after clpz, and commented out the fact clpz:monotonic, I get in continuation of the earlier toplevel interaction:

?- [file].
   true.
?- X #> 3.
   clpz:(X in 4..sup).
?- X #> 3.
   clpz:(X in 4..sup).
?- X #> 3.
   clpz:(X in 4..sup).
?- [file].
   true.
?- X #> 3.
   error(existence_error(procedure,monotonic/0),monotonic/0).
   error(existence_error(procedure,monotonic/0),monotonic/0).

Note the highly unexpected behaviour: Everything works exactly as expected when I (re-)consult the file once. Only after I re-consult it a second time do I get an unexpected existence error when posting X #> 3.

clpz:monotonic is declared as a dynamic predicate by library(clpz). I therefore expect it to fail if it is not defined.

Where exactly it is defined should have no influence on its dynamic property, and loading completely unrelated libraries should definitely have no influence at all on this property! That I get an existence error twice is even more unexpected!

@triska
Copy link
Contributor Author

triska commented Dec 18, 2023

This issue persists, I only need to load file.pl a third time:

?- [file]. % with the original file
   true.   % now make the changes mentioned above
?- [file]. % load the changed file
   true.
?- X #> 3.
   clpz:(X in 4..sup). % it appears to work
?- [file]. % load the changed file again
   true.
?- X #> 3.
   error(existence_error(procedure,monotonic/0),monotonic/0).
   error(existence_error(procedure,monotonic/0),monotonic/0).

@triska
Copy link
Contributor Author

triska commented Dec 18, 2023

Well done, thank you a lot!

@triska triska closed this as completed Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant