[m-dev.] [m-users.] Mode selection

Paul Bone paul at bone.id.au
Tue Oct 21 14:05:11 AEDT 2014


On Tue, Oct 21, 2014 at 10:25:17AM +1100, Mark Brown wrote:
> 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?

Neither, I'm saying that in cases like this it will probably be useful for
the language specification to specify what will happen.  A user will
reasonably want to know what will happen in this case and they shouldn't
have to lookup implementation specific behavour.

> What other choices for implied modes should be avoided? E.g., is det
> always preferred to nondet?

>From what I read in the compiler sources (trying to remember back to last
week) yes, det is preferred.


-- 
Paul Bone



More information about the developers mailing list