clause(<clause ref>,...), instead of clause(<callable>,...)
erase(<clause ref>) for an already erased clause
In both cases, SWI 9.1 correctly throws an exception, but Sicstus just fails silently… and I’m migrating an existing Sicstus app which depends on that devious behaviour
Any suggestions…? goal_expansion/2 is off the table, because the app does rather convoluted meta calls where clause(…) goals are expected to remain untouched.
For clause/2, that is understandable as a clause reference in SICStus is a compound term, but there are no clauses for it. In SWI-Prolog it is a blob, which is not a valid clause head. erase/1 in SICStus wants a ‘$ref’(Int,Int) term, but then just succeeds. I wonder whether they can ensure this is safe.
For now (and you seem to agree), I think SWI-Prolog is (more) right.
How to work around? Goal expansion is the cleanest, but if you like some hacking, you can also redefine clause/2 in the user module: Something like this:
Note that the redefine_system_predicate/1 call is not needed for erase/1 as only ISO standard predicates are protected against redefinition. You may need to change the blob/2 conditions a bit, depending on what is really passed. I.e., does it also pass record references to clause/2.