[m-rev.] for review: emit errors about purity mismatches with foreign clauses
Julien Fischer
juliensf at csse.unimelb.edu.au
Thu Jul 6 13:37:37 AEST 2006
On Thu, 6 Jul 2006, Julien Fischer wrote:
> > > @@ -2434,7 +2437,43 @@
> > > % Build the foreign_proc.
> > > goal_info_init(GoalInfo0),
> > > goal_info_set_context(Context, GoalInfo0, GoalInfo1),
> > > + %
> > > + % Check that the purity of the predicate/function declaration agrees
> > > + % with the (promised) purity of the foreign_proc. It is only okay for
> > > + % them to disagree if there is a `:- pragma promise_pure' or
> > > + % `:- pramga promise_semipure' declaration for the predicate or
> > > + % function.
> > > + %
> >
> > Could you explain why it's okay for them to disagree in this case?
>
> That's badly explained on my part. What I was getting at is that a pragma
> promise_{semipure,pure} sets the purity of a foreign proc if the purity of the
> foreign proc does not have its purity explicitly set via an attribute.
>
> :- pragma promise_semipure(foo/0).
> :- pragma foreign_proc("C",
> foo,
> [will_not_call_mercury],
> " ... ").
>
>
> e.g. the above foreign_proc is semipure not impure.
That's also not such a great explanation. The comment is saying that the
purity of the predicate declaration and the foreign code attribute are allowed
to disagree in the presence of a purity promise, e.g.
:- pred foo(string::in) is det.
:- pragma promise_pure(foo/1).
:- pragma foreign_proc("C",
foo(S::in),
[will_not_call_mercury, promise_semipure],
"...").
Here the declaration is pure and the foreign proc is semipure but because
of the purity promise that is okay. The situation that is not okay (and
which the compiler doesn't currently handle correctly**) is where the purity
of the declaration and the foreign_proc disagree in the absence of a purity
promise.
** It handles them correctly, i.e emits and error, in some cases but not
all.
Julien.
--------------------------------------------------------------------------
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