From jan@swi.psy.uva.nl  Thu Aug 10 11:37:07 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 LAA21006;
	Thu, 10 Aug 2000 11:37:02 +0200 (MET DST)
Received: (from jan@localhost)
	by gollem.swi.psy.uva.nl (8.9.3/8.9.3/SuSE Linux 8.9.3-0.1) id LAA13086;
	Thu, 10 Aug 2000 11:37:09 +0200
Date: Thu, 10 Aug 2000 11:37:09 +0200
Message-Id: <200008100937.LAA13086@gollem.swi.psy.uva.nl>
From: Jan Wielemaker <jan@swi.psy.uva.nl>
Subject: Re: Foreign language interface : PL_new_term_ref()
To: Lionel Ains <lains@caramail.com>, prolog@swi.psy.uva.nl
In-Reply-To: Lionel Ains's message of Thu, 10 Aug 2000 11:27:06 +0100 (WET DST)
Phone: +31 - 20 - 525 6121

> Just a quick question.
> I believe that any term created by PL_new_term_ref() is automatically destructed when it goes out o> f 
> scope. Could someone confirm?

Not really.  First of all, the scope is the embracement of
PL_open_foreign_frame() and its corresponding destruction
PL_close_foreign_frame().  This embracement is implicit around any function called
as a foreign predicate.  After the close, the *reference* is invalid.  The term
normally lives on until backtracking takes us before it was created or the
garbage collector removes it (if it has no other references).  When using
PL_discard_foreign_frame() instead of PL_close_foreign_frame(), not only
the references, but also the terms created and binding made are removed.

	--- Jan

