add call_residue_vars (SWI and SICStus 4 compatibility).
This commit is contained in:
parent
bddc09b963
commit
04fa96e8a0
17
docs/yap.tex
17
docs/yap.tex
@ -12097,6 +12097,23 @@ no
|
||||
The system only reports one invocation of @code{dif/2} as having
|
||||
suspended.
|
||||
|
||||
@item call_residue_vars(:@var{G},@var{L})
|
||||
@findex call_residue_vars/2
|
||||
@syindex call_residue_vars/2
|
||||
@cnindex call_residue_vars/2
|
||||
|
||||
Call goal @var{G} and unify @var{L} with a list of all constrained variables created @emph{during} execution of @var{G}:
|
||||
|
||||
@example
|
||||
?- dif(X,Z), call_residue_vars(dif(X,Y),L).
|
||||
dif(X,Z), call_residue_vars(dif(X,Y),L).
|
||||
L = [Y],
|
||||
dif(X,Z),
|
||||
dif(X,Y) ? ;
|
||||
|
||||
no
|
||||
@end example
|
||||
|
||||
@end table
|
||||
|
||||
@node Attributed Variables, CLPR, Co-routining, Extensions
|
||||
|
@ -560,6 +560,29 @@ frozen(V, LG) :-
|
||||
'$fetch_same_done_goals'(G0, D0, LV, GF).
|
||||
|
||||
|
||||
call_residue_vars(Goal,Residue) :-
|
||||
attributes:all_attvars(Vs0),
|
||||
call(Goal),
|
||||
attributes:all_attvars(Vs),
|
||||
% this should not be actually strictly necessary right now.
|
||||
% but it makes it a safe bet.
|
||||
sort(Vs, Vss),
|
||||
sort(Vs0, Vs0s),
|
||||
'$ord_remove'(Vss, Vs0s, Residue).
|
||||
|
||||
'$ord_remove'([], _, []).
|
||||
'$ord_remove'([V|Vs], [], [V|Vs]).
|
||||
'$ord_remove'([V1|Vss], [V2|Vs0s], Residue) :-
|
||||
( V1 == V2 ->
|
||||
'$ord_remove'(Vss, Vs0s, Residue)
|
||||
;
|
||||
V1 @< V2 ->
|
||||
Residue = [V1|ResidueF],
|
||||
'$ord_remove'(Vss, [V2|Vs0s], ResidueF)
|
||||
;
|
||||
'$ord_remove'([V1|Vss], Vs0s, Residue)
|
||||
).
|
||||
|
||||
call_residue(Goal,Residue) :-
|
||||
var(Goal), !,
|
||||
'$do_error'(instantiation_error,call_residue(Goal,Residue)).
|
||||
|
@ -512,6 +512,7 @@ source_module(Mod) :-
|
||||
call_cleanup(:,:),
|
||||
call_cleanup(:,?,:),
|
||||
call_residue(:,?),
|
||||
call_residue_vars(:,?),
|
||||
catch(:,+,:),
|
||||
clause(:,?),
|
||||
clause(:,?,?),
|
||||
|
Reference in New Issue
Block a user