users-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AGAIN: non-determinist foreign predicate + cut


From: Jorge Marques Pelizzoni
Subject: AGAIN: non-determinist foreign predicate + cut
Date: Thu, 22 Mar 2001 12:20:44 -0300

Sorry but I was silly enough to ask the following question without having subscribed to this discussion list. If there have been answers, could someone please forward them to me?
 
Grateful and ashamed,
 
        Jorge.
 
----- Original Message -----
Sent: Wednesday, March 21, 2001 12:22 PM
Subject: non-determinist foreign predicate + cut

Hi! I´m new to Gnu Prolog and have a doubt I couldn´t sort out in the doc: what exactly happens in proving ´c_predicate1´ below:
 
        c_predicate1(X) :- nondet_c_predicate(X), !.
 
supposing ´nondet_c_predicate´ is a non-deterministic foreign predicate? 
 
If ´nondet_c_predicate´ succeeds, will the engine, upon bactracking, ´secretly´ exhaust the additional instances till the implementation triggers No_More_Choice? If not, this seems to make it quite awkward for a foreign predicate to handle dynamic structures [some structure could (i) be built when Get_Choice_Counter() == 0, (ii) have its address stored in the choice buffer and (iii) be finally freed just before No_More_Choice()].
 
One fine solution to this problem would be to provide a foreign/2 option defining a C abort function for the foreign predicate, which would only be called in the event of a cut, being thus able to access the choice buffer and perform any necessary clean-up. Do we have anything of this sort? Have you got any other way round this problem?
 
Thanx,
   
        Jorge.
 
P.S.: I take the trouble because I think Gnu Prolog provides the best Prolog-to-C interface ever.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]