Flag to Ignore Unknown Predicate Errors in s(CASP) isn't working

In Is it possible to suppress warnings in SWISH? - #3 by JasonMorris I asked for a way to avoid problems with scasp_predicate … does not exist" errors, and @jan hooked me up with the

:- set_prolog_flag(scasp_unknown, fail).

But I have code that is still throwing that error, when it calls scasp/2 against a predicate that hasn’t been defined anywhere in the code. I’ve tried making it dynamic, to no avail, which makes sense, because my system is compiling code to a file, and then consulting it. Nothing is being asserted.

What I think is the same problem can be seen by opening an empty s(CASP) program in SWISH and running the query ? a(X).

scasp_predicate `'04c200ae-e39a-4b04-a78f-0f90a0e09694:a'/1' does not exist

I want to be able to specify that for certain predicates, their non-existence should make them fail instead of throwing an error when used as the first parameter to scasp/2. How can I do that?

Thanks in advance.

As is, s(CASP) raises an error if the predicate immediately called by scasp/2 is undefined and the flag only takes care of indirectly called predicates. The rationale is that it makes very little sense to call an already undefined predicate. I agree it is also somewhat inconsistent. If you have some wrapper around anyway, you can use clause/2 or predicate_property/2 to check the predicate is undefined and simply fail.

1 Like

That makes sense. My use-pattern is atypical, and probably not long for this world, anyway. I was able to solve the problem in the short term by handling the error differently in Python. Thanks!