Could you advise me on how to implement Richard O'Keefe's retract_exactly/1? My understanding is that it is still not possible in Logtalk without reaching through to the backend Prolog.
Code: Select all
retract_exactly(Clause) :- ( nonvar(Clause) -> Clause = :-(Head,Body) ; Head = Clause, Body = true ), must_be_callable(Head), functor(Head, F, N), functor(Skel, F, N), clause(Skel, Rest, DbRef), :-(Skel,Rest) =@= :-(Head,Body), erase(DbRef).
I first raised this on the SWI-prolog mailing list back in 2007 and I still have the issue.Consider these two cases:
Case 1. clause db contains:
Now, retract(p(Z)) will remove p(a).
Case 2. clause db contains the same clauses but in reverse order:
Again, retract(p(Z)) and this time p(X) is removed.
What if a predicate is required that retracts only structurally-equivalent clauses - ie retract_exactly(p(Z)) in both cases above removes p(X) and leaves p(a).
http://osdir.com/ml/lang.swi-prolog.gen ... 00008.html
Just wondering if this can be done in Logtalk yet.