users-prolog
[Top][All Lists]
Advanced

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

non-determinist foreign predicate + cut


From: Jorge Marques Pelizzoni
Subject: non-determinist foreign predicate + cut
Date: Wed, 21 Mar 2001 12:22:17 -0300

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]