[m-dev.] call for opinions on promise_same_solutions syntax

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Feb 27 15:28:51 AEDT 2006


On 27-Feb-2006, Julien Fischer <juliensf at cs.mu.OZ.AU> wrote:
> were originally implementing mutables:
> 
> 	:- pred p(io::di, io::uo) is det.
> 
> 	p(!IO) :-
> 		promise_pure(
> 				impure set_mutable(3)
> 		).
> vs.
> 	:- pragma promise_pure(p/2).
> 	:- pred p(io::di, io::uo) is det.
> 
> 	p(!IO) :-
> 		impure set_mutable(3).

> The problem with the former is that at many optimization levels the compiler
> will happily optimize it away.

I don't really see any reason why the compiler should be able to do anything
with either one of these definitions that it cannot do with the other,
and that includes inlining. Anything that distinguishes these two would
fail the law of least astonishment.

In this case, either way you do it, the promise is wrong, because calling
set_mutable isn't a pure computation. In other words, you lied to the compiler,
so it is entitled to its revenge.

> <http://www.cs.mu.oz.au/research/mercury/mailing-lists/mercury-reviews/mercury-reviews.200512/0052.html>
> 
> Any discussion of adding `promise_equivalent_clauses should take place as
> part of this.

Ok, I'll review that and set up a time to hash it out.

Zoltan.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list