[m-rev.] [reuse] bugfix: reuse dead cells from negated goals

Nancy Mazur Nancy.Mazur at cs.kuleuven.ac.be
Fri Jul 6 19:43:17 AEST 2001


Hi,


===================================================================


Estimated hours taken: 0.3
Branches: reuse

sr_choice used to allow the following reuse situation: 

:- type t ---> f(int, int); g(int, int). 
:- pred transform(t::in, t::out) is det. 
transform(A, B):- 
	(
		not( A = f(_, _) )	% A considered dead after this goal
	-> 
		B = g(1, 2)		% reuse A
	; 
		B = g(3, 4)
	).

A might die in the negated goal, but when leaving the negation, A is
still dead, but you cannot always be sure of the functor A is having. So
reuse of A shouldn't be allowed. 

sr_choice.m:
	Don't take into account cells dying in negated goals. 



Index: sr_choice.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/sr_choice.m,v
retrieving revision 1.1.2.23
diff -u -r1.1.2.23 sr_choice.m
--- sr_choice.m	2001/07/05 15:33:31	1.1.2.23
+++ sr_choice.m	2001/07/06 09:32:44
@@ -124,7 +124,11 @@
 	{ Goal = some(Vars, CanRemove, SomeGoal) }.
 
 apply_constraint_2(Constraint, not(Goal0) - GoalInfo, not(Goal) - GoalInfo) -->
-	apply_constraint_2(Constraint, Goal0, Goal).
+	=(InitNotInfo),
+	% A negated goal cannot introduce new dead cells to the map of
+	% available dead cells, as those dead cells are not allowed to 
+	% be reused outside of the negated goal. 
+	{ apply_constraint_2(Constraint, Goal0, Goal, InitNotInfo, _) }.
 
 apply_constraint_2(Constraint, conj(Goal0s) - GoalInfo,
 		conj(Goals) - GoalInfo) -->
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list