setof should cleanup in case of throw.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@786 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
42ed54c331
commit
773f2fb56e
@ -97,7 +97,6 @@ read_sig.
|
||||
true
|
||||
)
|
||||
),
|
||||
'$db_clean_queues'(0),
|
||||
'$startup_reconsult',
|
||||
'$startup_goals'
|
||||
;
|
||||
@ -1108,8 +1107,6 @@ expand_term(Term,Expanded) :-
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% catch/throw implementation
|
||||
|
||||
/* new design, not working for now: */
|
||||
|
||||
% at each catch point I need to know:
|
||||
% what is ball;
|
||||
% where was the previous catch
|
||||
|
11
pl/setof.yap
11
pl/setof.yap
@ -45,6 +45,7 @@ findall(Template, Generator, Answers, SoFar) :-
|
||||
% starts by calling the generator,
|
||||
% and recording the answers
|
||||
'$findall'(Template, Generator, Ref, _, _) :-
|
||||
'$catch'(Error,'$clean_findall'(Ref,Error),_),
|
||||
'$execute'(Generator),
|
||||
'$db_enqueue'(Ref, Template),
|
||||
fail.
|
||||
@ -52,6 +53,16 @@ findall(Template, Generator, Answers, SoFar) :-
|
||||
'$findall'(_, _, Ref, SoFar, Answers) :-
|
||||
'$collect_for_findall'(Ref, SoFar, Answers).
|
||||
|
||||
'$clean_findall'(Ref,_) :-
|
||||
'$db_dequeue'(Ref,_),
|
||||
fail.
|
||||
'$clean_findall'(_,Ball) :-
|
||||
% get this off the unwound computation.
|
||||
copy_term(Ball,NewBall),
|
||||
% get current jump point
|
||||
'$jump_env_and_store_ball'(NewBall).
|
||||
|
||||
|
||||
% by getting all answers
|
||||
'$collect_for_findall'(Ref, SoFar, Out) :-
|
||||
( '$db_dequeue'(Ref, Term) ->
|
||||
|
@ -372,7 +372,7 @@ system_predicate(P) :-
|
||||
'$pred_exists'(T,M).
|
||||
|
||||
'$current_predicate3'(M,A/Arity) :- !,
|
||||
'$current_predicate'(M,A,Arity),
|
||||
'$current_predicate_for_atom'(A,M,Arity),
|
||||
functor(T,A,Arity),
|
||||
'$pred_exists'(T,M).
|
||||
'$current_predicate3'(M,BadSpec) :- % only for the predicate
|
||||
|
Reference in New Issue
Block a user