[m-rev.] diff: Restore promise_pure declaration for catch_impl.
novalazy at gmail.com
Wed Oct 15 18:16:09 AEDT 2014
I inadvertently deleted a promise_pure declaration for catch_impl in
commit 3f220a009735b1bda71e1ce320025e66811fb4b5. It is necessary in
java and csharp grades as catch_impl is implemented with mode-specific
clauses in those grades so the compiler infers impure.
Restore the promise_pure declaration.
Add Zoltan's explanation for why catch_impl is impure.
Explain why we currently pretend catch_impl is pure.
diff --git a/library/exception.m b/library/exception.m
index 04608e5..ac09891 100644
@@ -625,9 +625,15 @@ exc_univ_value(Univ) = univ.univ_value(Univ).
:- inst handler == (pred(in, out) is det).
-% catch_impl/3 is actually impure (why?).
-% XXX Mercury supports impure higher-order pred terms now.
+% catch_impl/3 is actually impure. If the call tree of p(...) contains more
+% than one throw, it returns just ONE of the exceptions p(...) can throw,
+% and the declarative semantics does not say WHICH one it returns.
+% XXX We don't declare catch_impl as impure because there do not yet exist
+% unsorted_solutions/2 and unsorted_aggregate/2 predicates that take impure
+% higher-order pred terms.
+:- pragma promise_pure(catch_impl/3).
:- /* impure */
pred catch_impl(pred(T), handler(T), T).
:- mode catch_impl(pred(out) is det, in(handler), out) is det.
More information about the reviews