Subject: Re: Exceptions handling in foreign code

From: Jan Wielemaker <[email-masked]>
Date: Fri, 18 Aug 2000 11:33:44 +0200

On Fri, 18 Aug 2000, Lionel Ains wrote:
>
>Hello,
>
>I would like to know more about exception handling inside a foreign code library.
>In a non-deterministic predicate, if an exception is raised somewhere while the foreign
>non-deterministic predicate is still waiting for a redo, how can I clean the environment? (Is the
>predicate called with PL_CUTTED?).

Yip.  Please note that all Prolog arguments (term_t) are 0, only the
handle is what you've passed in the last PL_redo_*().  At the moment
you cannot tell whether you're cleaned due to a cut or exception. Still
wondering whether that is worth adding (it will be incompatible!).

>If the foreign non-deterministic predicate raises itself an exception, does it have to clean the
>environment or is it recalled the same way as described in the question before (exception raised) to
>clean the environment?

You only need to handle the PL_CUTTED if you returned using PL_redo_*().
Thus, if you return deterministically (which includes using an
exception) you will not be called again.

	Regards --- Jan