[m-dev.] [m-users.] Mode selection
Mark Brown
mark at mercurylang.org
Tue Oct 21 10:25:17 AEDT 2014
Moving this to the developers list.
On Fri, Oct 17, 2014 at 5:40 PM, Paul Bone <paul at bone.id.au> wrote:
> I agree that there should be a full definition for the strict sequential
> semantics. But maybe there should be some "rules" (incomplete definition)
> for the normal semantics.
We're not in disagreement - I have already given an example of such a rule.
> For example it may be useful to specify that:
>
> :- pred foo(a, b).
> :- mode foo(in, out) is multi.
> :- mode foo(out, in) is det.
>
> and
>
> foo(bar, baz).
>
> Results in the second mode (the det mode) being selected. That is it
> probably shouldn't be up to Mercury implementations to choose this obviously
> more efficient mode when it can be specified in the language specification.
> Or can someone think of a reason why a reasonable implementation might
> select the first mode?
In the ordering of conjuncts
X = bar, foo(X, Y), Y = baz,
the implementation has no choice but to select the first mode. Or are
you saying that this ordering shouldn't be allowed?
What other choices for implied modes should be avoided? E.g., is det
always preferred to nondet?
Cheers,
Mark.
More information about the developers
mailing list