[mercury-users] det & cc_multi question
xonixx at gmail.com
Sun May 16 23:46:07 AEST 2010
Hi Dear sirs
let's look at code
:- module tst2.
:- import_module io.
:- pred main(io, io).
:- mode main(di, uo) is det.
:- import_module solutions, list, int.
promise_equivalent_solutions [L] unsorted_solutions((pred(E::out) is
E mod 3 = 0
Note, that without "promise_equivalent_solutions [L]" it gives
$ mmc tst2
tst2.m:008: In `main'(di, uo):
tst2.m:008: error: determinism declaration not satisfied.
tst2.m:008: Declared `det', inferred `multi'.
tst2.m:017: call to `solutions.unsorted_solutions'((pred(out) is nondet),
tst2.m:017: out) can succeed more than once.
tst2.m:017: Error: call to predicate `solutions.unsorted_solutions'/2 with
tst2.m:017: determinism `cc_multi' occurs in a context which requires all
I've read some documentation on cc_multi, and I seem to understand the
meaning of cc_multi. It's used when we defining predicate as being multi,
but using it in place where we nead only 1 solution (actually, anyone.. this
is determined by compiler what solution to return taking in mind
optimization concerns). What I can't understand is why should I explicitely
convert it to det with "promise_equivalent_solutions [L]". Why compiler is
not smart enough to make this automatically? I know that I could
alternatively make cc_multi my main predicate.. But what if I have some
architecture with many det predicates. This would mean that I should then
turn all those preds to cc_multi.. I don't like this..
I've also read this thread that seem to relate to my questions
but still it's not very clear.
Also, it seems not very logical to me that aggregate and solutions
predicates perform sorting & removing duplicates. It seems more logical that
those perform as their unsorted_ counterparts and additional sorted_
versions be present.
I beg pardon for my, most likely, stupid questions =)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the users