Search code examples
prologprolog-assert

What is the difference between abolish/1 and retractall/1?


From reading the manual, I can't seem to find the difference between the two.

The manual says:

It is advised to use retractall/1 for erasing all clauses of a dynamic predicate.

So I chose to use retractall/1 in my program; however, I wonder what the difference is.


Solution

  • The retractall/1 standard built-in predicate can be used to remove all clauses for a dynamic predicate but the predicate will still be known by the runtime. The abolish/1 standard built-in predicate, in the other hand, not only removes all predicate clauses but also makes the predicate unknown to the runtime. If you try to call a dynamic predicate after removing all its clauses using retractall/1, the call simply fails. But if you abolish a dynamic predicate, calling it after will result in a predicate existence error.