[mercury-users] Using exceptions without cc_multi
api at gmx.de
api at gmx.de
Tue Aug 26 20:34:02 AEST 2003
Hello mercury users!
When using try and throw in mercury, I did not find a way to use a try
block within an ordinary clause, say, of a predicate with determinism
declaration semidet instead of cc_multi. So something like
:- module tst_except.
:- implementation.
:- import_module exception.
:- pred q(string::in,string::out) is semidet.
:- pred p(string,string).
:- mode p(in, out) is semidet.
p(A,B) :-
try(q(A), Result),
(Result = succeeded(B)
;
Result = exception(E),
%% handle E
fail
).
q("A", "B").
q("B", _) :-
throw("no").
will not work because of the determinism declaration of try to be
cc_multi, but p being semidet. But if p is semidet for very good reasons
(very far down the call tree), then there should be any other way of
using exceptions. Unfortunately, I have not been able to find out how.
Does anyone know how to use exceptions properly?
Thanks
André
P.S. The compiler errors are
tst_except.m:011: Error: call to predicate `exception:try/2' with
determinism `cc_multi'
tst_except.m:011: occurs in a context which requires all solutions.
tst_except.m:009: In `p(in, out)':
tst_except.m:009: error: determinism declaration not satisfied.
tst_except.m:009: Declared `semidet', inferred `nondet'.
tst_except.m:011: call to `try((pred(out) is semidet), out)' can
succeed more than once.
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list