From jan@swi.psy.uva.nl  Fri Aug 18 11:38:51 2000
Received: from gollem.swi.psy.uva.nl (root@gollem [145.18.152.30])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id LAA06814;
	Fri, 18 Aug 2000 11:38:46 +0200 (MET DST)
Received: from localhost (localhost [[UNIX: localhost]])
	by gollem.swi.psy.uva.nl (8.9.3/8.9.3/SuSE Linux 8.9.3-0.1) id LAA22772;
	Fri, 18 Aug 2000 11:39:01 +0200
From: Jan Wielemaker <jan@swi.psy.uva.nl>
Organization: SWI, University of Amsterdam
To: Lionel Ains <lains@caramail.com>, prolog@swi.psy.uva.nl
Subject: Re: Exceptions handling in foreign code
Date: Fri, 18 Aug 2000 11:33:44 +0200
X-Mailer: KMail [version 1.0.28]
Content-Type: text/plain
References: <966593778022268@caramail.com>
In-Reply-To: <966593778022268@caramail.com>
MIME-Version: 1.0
Message-Id: <00081811390100.22303@gollem>
Content-Transfer-Encoding: 8bit

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

