How does consulting a file (with facts) work internally? When I consult a file containing facts multiple times, even when the file changes, the facts are not duplicated (asserted twice). When I remove a fact in the file and reconsult it, the fact is also gone. Does SWI Prolog keep a reference internally to a file the fact was defined it and removes it on reconsulting? Is this behaviour part of the standard?
I found info (from 1993 ) here, but I am not sure how much of it applies to SWI. Quote:
There are a couple of problems with getting consult/1 into the standard. One problem is what it means to consult the same file more than once. Quintus Prolog and some others use the “reconsult” semantics (based on the reconsult predicate in DEC10 Prolog) which deletes previous definition of each predicate that appears in the file. This is not quite “right” in the case where a predicate has been deleted from a file and the file is then consulted again, since there may still be calls to the deleted predicate. Another possibility is to have systems “unload” all the predicates that previously were defined in the file before consulting it a second time. This imposes some implementation overhead, and also makes it imperative that the Prolog system can always identify whether a file is one that has been previously consulted, which is not possible in general, especially in cases where Prolog states can be saved and then re-run later, possibly on a different machine.