2
votes

I am pretty new to prolog. Using SICStus, when I make a change to a file that has already been consulted, SICStus does not recognise the changes. Only way is for me to close the window and start it again. But obviously this is not practical as closing the window everytime you make a change to the file is not only annoying but time wasting. I am using Sicstus 4.2.1, the windows version. So far, I have tried the commands consult(file), reconsult(file), compile(file) but none made a difference. SICStus simply ignores the changes made till I close and open the window.

Say, for example, I had the predicate test/2. Then I deleted it and saved the file. And then I type reconsult(file). My expectation was that SICStus will recognise the changes made and say that the predicate does not exist. But it continues as though it exists. Only after I close the window and start all over again will it rightly complain that the predicate does not exist.

Strangely though, it recognises a newly added predicate with reconsult(file) but if it is changed or deleted, it does not.

1
reconsult(file) should recognize changes to a predicate, i.e. if you add or remove clauses. Is that not what happens for you? PS. In the SICStus IDE you can restart the SICStus toplevel with the press of a button.Per Mildner
In my case, no, reconsult does not recognise the changes at all.Enigma
This is strange and not what happens when I try this in 4.2.1. Please send a reproducer to SICStus support so that I can investigate.Per Mildner

1 Answers

2
votes

consult/1, reconsult/1, and '.'/2 — are all legacy built-ins first defined in the 1970ies1. Today they are just for quick and dirty compilation. The semantics of these constructs was (and actually still is), so implementation specific that it was impossible to agree upon a clean semantics ready for standardization. And you pointed to one of those weak points. Yes, once defined, you cannot implicitly undefine a predicate. Use SICStus' implementation specific abolish/2 to delete a predicate.

In general, rather use ensure_loaded/1 in stead, for this will check whether or not the file modification date has changed. A more general way to use this is by issuing make. But again, be warned certain changes are not taken into account properly. I still use make. to reload changed files.

The cleanest way is to use modules, and there again, changes in the interface are not taken into account properly, instead, some warning is issued:

| ?- use_module(modulefile).
% compiling /home/ulrich/SO/modulefile.pl...
* predicate test/2 imported by user from modulefile is private
* Approximate lines: 1-2, file: '/home/ulrich/SO/modulefile.pl'
%  module modulefile imported into user
% compiled /home/ulrich/SO/modulefile.pl in module modulefile, 0 msec 2768 bytes
yes

1 The earliest document I am aware of is the User's guide to DECsystem-10 Prolog of 1978-09. A version of 1978-10 with errata is here.