[m-rev.] private_builtin.m improvements & purity warning bugfix

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Dec 13 22:18:17 AEDT 2001


On 13-Dec-2001, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> On 13-Dec-2001, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > compiler/purity.m:
> > 	Fix a bug where it was reporting spurious warnings about
> > 	"predicate declared `impure' but actually `pure'"
> > 	for predicates defined with both Mercury code and
> > 	`pragma foreign_proc' declarations.
> > 	If the user declares `pragma foreign_proc' code to be
> > 	impure, then the compiler should always respect that.
> 
> This should probably be a separate change.

Well, the two parts are mutually interdependent,
in the sense that the purity.m change is needed
for the private_builtin.m change to work,
and the code added to private_builtin.m is the test
case for the purity.m change.

Maybe you're right, but in any case,
I'm afraid I've already committed it.

> There should also be a test case.

Code which exercises this bug is in library/private_builtin.m
after my change.  Do we really need a separate test case?

> > Index: library/private_builtin.m
> > ===================================================================
> > +	% XXX Why isn't this marked as `impure'?
> > +:- pred free_heap(_T).
> > +:- mode free_heap(di) is det.
> 
> It should be.

I agree, but that should be a separate change ;-)
It might require further changes elsewhere.
E.g. any code which generates calls to free_heap might need to be
changed also, to add the correct impurity annotations...
I think currently such code exists only on a branch?

> > +free_heap(_::di) :-
> > +	error("private_builtin__free_heap/1").
> 
> s/error/sorry/

Well spotted.

> > +:- pragma foreign_proc("MC++", free_heap(_Val::di),
> > +	[will_not_call_mercury, thread_safe], "
> > +	mercury::runtime::Errors::SORRY(""foreign code for free_heap/1"");
> > +").
> 
> It's probably better to just remove this.

OK.

----------

Estimated hours taken: 0.25
Branches: main

library/private_builtin.m:
	Address stayl's review comments on my previous change.

Index: private_builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/private_builtin.m,v
retrieving revision 1.84
diff -u -d -u -r1.84 private_builtin.m
--- private_builtin.m	13 Dec 2001 09:06:09 -0000	1.84
+++ private_builtin.m	13 Dec 2001 11:12:55 -0000
@@ -1066,16 +1066,11 @@
 % default (Mercury) implementation for free_heap/1
 % This should be overridden by the appropriate foreign language implementation.
 free_heap(_::di) :-
-	error("private_builtin__free_heap/1").
+	sorry("private_builtin__free_heap/1").
 
 :- pragma foreign_proc("C", free_heap(Val::di),
 	[will_not_call_mercury, thread_safe],
 	"MR_free_heap((void *) Val);").
-
-:- pragma foreign_proc("MC++", free_heap(_Val::di),
-	[will_not_call_mercury, thread_safe], "
-	mercury::runtime::Errors::SORRY(""foreign code for free_heap/1"");
-").
 
 % default (Mercury) implementations for mark_hp/1 and restore_hp/1.
 % This should be overridden by the appropriate foreign language implementation.
-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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