scryer-prolog
scryer-prolog copied to clipboard
use_module discard withdraw predicate definition
I have noticed this behaviour (with linux OS)
[I] cydu > more a.pl
:- module(a, [
test_a/1
]).
test_a(a).
[I] cydu > more b.pl
:- module(b, [
test_b/1
]).
:- use_module(a).
test_b(X) :-
test_a(X).
[I] cydu > scryer-prolog
?- use_module(a).
true.
?- test_a(X).
X = a.
?- use_module(b).
true.
?- test_a(X).
caught: error(existence_error(procedure,test_a/1),test_a/1)
?-
I am expecting test_a(X) succeed.
I agree that it should succeed.
Just to note, test_a/1
is still available and works if we use explicit module qualification:
?- a:test_a(X). X = a.
I think a new predicate like context_module/1
would be useful, to help us find out the current context from which we are calling a predicate. The default context should be user
, and loading a module should not change the context.
This seems to work in the current master:
?- use_module(a).
true.
?- test_a(X).
X = a.
?- use_module(b).
true.
?- test_a(X).
X = a.