[m-rev.] for review: make foreign_proc impure by default

Tyson Dowd trd at cs.mu.OZ.AU
Mon Jan 28 17:39:05 AEDT 2002


On 21-Jan-2002, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> On 21-Jan-2002, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> > Estimated hours taken: 12
> > Branches: main
> > 
> > Make foreign_proc impure by default.
> 
>  
> > Index: compiler/purity.m
> > ===================================================================
> > RCS file: /home/mercury1/repository/mercury/compiler/purity.m,v
> > retrieving revision 1.40
> > diff -u -r1.40 purity.m
> > --- compiler/purity.m	16 Dec 2001 08:11:11 -0000	1.40
> > +++ compiler/purity.m	20 Jan 2002 12:15:23 -0000
> > @@ -563,8 +563,8 @@
> >  	% If this clause doesn't apply to all modes of this procedure,
> >  	% i.e. the procedure has different clauses for different modes,
> >  	% then we must treat it as impure.
> > -	% XXX Currently `:- pragma foreign_proc' procedures are
> > -	% assumed to be pure. This will change.
> > +	% foreign_proc procedures are not treated as impure because they
> > +	% have different clauses for different modes
> 
> I parse this sentence as saying that foreign_proc procedures are not
> treated as impure. It would be better to say that the default impurity
> of foreign proc procedures is handled when processing the foreign_proc
> goal.
> 
> > @@ -774,22 +774,22 @@
> >  	compute_goal_purity(Goale0, Goale, InClosure, Purity3),
> >  	{ worst_purity(Purity1, Purity2, Purity12) },
> >  	{ worst_purity(Purity12, Purity3, Purity) }.
> > -compute_expr_purity(Ccode, Ccode, _, _, Purity) -->
> > -	{ Ccode = foreign_proc(Attributes, PredId, _,_,_,_,_) },
> > -	{ purity(Attributes, AttributesPurity) },
> > -
> > -	%
> > -	% If there were no purity attributes, the purity of the goal
> > -	% is the purity of the predicate.
> > -	% XXX Currently the default purity is `pure'. Eventually it
> > -	% should default to `impure', and require promises for any
> > -	% other purity levels, i.e. Purity = AttributesPurity.
> > -	%
> > +compute_expr_purity(ForeignProc0, ForeignProc, _, _, Purity) -->
> > +	{ Attributes = ForeignProc0 ^ foreign_attr },
> > +	{ PredId = ForeignProc0 ^ foreign_pred_id },
> 
> It's probably better style for each arm of the switch to mention
> the functor being handled explicitly, rather than implicitly in
> a field access.
> 
> Otherwise this change looks fine.


diff -u compiler/purity.m compiler/purity.m
--- compiler/purity.m
+++ compiler/purity.m
@@ -563,8 +563,9 @@
 	% If this clause doesn't apply to all modes of this procedure,
 	% i.e. the procedure has different clauses for different modes,
 	% then we must treat it as impure.
-	% foreign_proc procedures are not treated as impure because they
-	% have different clauses for different modes
+	% the default impurity of foreign_proc procedures is handled when
+	% processing the foreign_proc goal -- they are not counted as impure
+	% here simply because they have different clauses for different modes
 	{
 		( applies_to_all_modes(Clause0, ProcIds)
 		; GoalType = pragmas
@@ -775,6 +776,7 @@
 	{ worst_purity(Purity1, Purity2, Purity12) },
 	{ worst_purity(Purity12, Purity3, Purity) }.
 compute_expr_purity(ForeignProc0, ForeignProc, _, _, Purity) -->
+	{ ForeignProc0 = foreign_proc(_, _, _, _, _, _, _) },
 	{ Attributes = ForeignProc0 ^ foreign_attr },
 	{ PredId = ForeignProc0 ^ foreign_pred_id },
 	ModuleInfo =^ module_info,

-- 
       Tyson Dowd           # 
                            #  Surreal humour isn't everyone's cup of fur.
     trd at cs.mu.oz.au        # 
http://www.cs.mu.oz.au/~trd #
--------------------------------------------------------------------------
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