I create a prolog file listen.pl with the following contents:
:- listen(who, writeln('I heard you')).
which I later change to
:- listen(who, writeln('I heard you again')).
In prolog, I do the following:
swipl listen.pl
Welcome to SWI-Prolog (threaded, 64 bits, version 9.0.2)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.
For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).
?- broadcast(who).
I heard you
true.
?- make.
% /Repos/my_project/listen compiled 0.00 sec, -1 clauses
true.
?- broadcast(who).
I heard you again
I heard you
true.
?- listening(A, B, C).
A = user,
B = who,
C = user:writeln('I heard you again') ;
A = user,
B = who,
C = user:writeln('I heard you').
?-
As you can notice, the listen/2 predicates in my prolog are not unlistened when calling make/0.
As a result, the latest version of my listen statement are added up to the previous ones.
Is this the expected behaviour of make/0?
As a work around, I tried to add an unlisten/1 statement
listen.pl
:- unlisten(user).
:- listen(who, writeln('I heard you more')).
This works sometimes, but not always:
swipl listen.pl
?- broadcast(who).
I heard you
true.
?- make.
% /Repos/cdj_project/listen compiled 0.00 sec, -1 clauses
true.
?- broadcast(who).
I heard you again
true.
?- make.
true.
% make did not "notice" the file update
?- broadcast(who).
I heard you again
true.
% the message should now be 'I heard you more'
Any help in this matter would be appreciated.