I’d like to use the is
predicate from some C code in such a way that any generated exceptions get a sniff (not shown below) and then are optionally re-generated. Prototype C code (as a function) looks like:
static int is_eval(term_t result, term_t exp) {
static predicate_t pred_is = 0;
if (!pred_is) pred_is = PL_predicate("is",2,"system"); //initialize once
term_t args0 = PL_new_term_refs(2);
PL_put_term(args0 ,result);
PL_put_term(args0+1,exp);
int res = PL_call_predicate(NULL,PL_Q_CATCH_EXCEPTION | PL_Q_EXT_STATUS,pred_is,args0);
if (res == PL_S_EXCEPTION)
return PL_raise_exception(PL_exception(0));
else
return res;
}
The no exception case seems to work as intended, but if an arithmetic exception is generated during evaluation, the result is success although nothing is bound to the result
term.
Is this my bug?