Suppose I want to load a new definition of a predicate from a new module:
% mod_1.pl: :-module(mod_1, [exported/0]). exported :- writeln(mod_1). % mod_2.pl: :-module(mod_2, [exported/0]). exported :- writeln(mod_2).
I don’t want to have the two definitions living side-by-side, as in polymorphism. I want to replace one definition with the other. However, if I load mod_2 after loading mod_1 that will raise a permission error:
?- use_module(mod_1). true. ?- use_module(mod_2). ERROR: import/1: No permission to import mod_2:exported/0 into user (already imported from mod_1) true.
But if I define exported/0 in a traditional file, I can load a new definition from a different file with only a warning:
% trad_1.pl: exported :- writeln(trad_1). % trad_2.pl: exported :- writeln(trad_2). ?- [trad_1]. true. ?- exported. trad_1 true. ?- [trad_2]. Warning: c:/users/.../trad_2.pl:1: Warning: Redefined static procedure exported/0 Warning: Previously defined at c:/users/.../trad_1.pl:1 true. ?- exported. trad_2 true.
Can I avoid the permission errors and still load different definitions of a predicate from different files, whle not giving up the advantages of using modules?
P.S. I’ve asked this question before but in a more confusing manner- apologies and I hope this one makes more sense.