scryer-prolog icon indicating copy to clipboard operation
scryer-prolog copied to clipboard

use_module discard withdraw predicate definition

Open cduret opened this issue 4 years ago • 2 comments

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.

cduret avatar May 24 '20 12:05 cduret

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.

triska avatar May 24 '20 13:05 triska

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.

bakaq avatar Dec 12 '23 19:12 bakaq