[m-rev.] for review: make foreign_procs a top-level item

Peter Wang novalazy at gmail.com
Fri Aug 4 09:52:05 AEST 2023


On Fri, 04 Aug 2023 00:24:35 +1000 "Zoltan Somogyi" <zoltan.somogyi at runbox.com> wrote:
> 
> That comment also outlines a longer term proposal: deprecating promise
> pure/semipure pragmas. I would also like feedback on that, but this question
> is not that urgent.

I had to remind myself of the case where promise_pure/semipure pragmas
are not obsoleted by the promise_pure/semipure scopes. In a discussion
on mercury-developers[1], Ian pointed out that:

    :- pred pure_p(..., io::di, io::uo) is det.

    pure_p(..., !IO) :-
	promise_pure ( impure impure_p(...) ).

is wrong, and should be:

    :- pragma promise_pure(pure_p).

    pure_p(..., !IO) :-
	impure impure_p(...).

Elsewhere in the same thread, Julien mentioned that your preferred way
to handle this case would be to "put an explicit unification for the I/O
state inside the promise_pure scope rather than use a pragma."

BTW, in 2008, Ian made a change (commit cc2cf5fba) to use
pragma promise_pure around benchmarking.turn_off_profiling, etc.
This was inadvertently(?) changed back in commit 0d7c8a765 to use
promise_pure scopes.

Peter

[1] http://lists.mercurylang.org/archives/developers/2008-April/015028.html
    Message-ID: <20080415050020.GH6684 at xerxes>


More information about the reviews mailing list