[m-dev.] polymorphic modes

David Overton dmo at ender.cs.mu.oz.au
Wed Feb 9 13:38:54 AEDT 2000


Hi,

Several weeks ago on the mercury_users list there was a discussion
about adding polymorphic modes where the inst parameters were
constrained to being ground(shared).

I proposed a syntax something like

	:- mode p(in(I), out(I)) <= ground(I).

to describe these constrained polymorphic modes.

I have now implemented these modes within the mode checker, but I have
not yet added the new syntax because I think this is something that
should be dicussed a bit first.

What I have currently done is assume that all inst parameters in
predicate and function mode declarations are implicitly constrained to
be ground(shared).  E.g.

	:- mode p(in(I), out(I)).

works for all insts, I, that are ground(shared), such as:

	:- mode p(in(ground), out(ground)).
	:- mode p(in(pred(in, in) is semidet), out(pred(in, in) is semidet)).
	:- mode p(in(bound(foo)), out(bound(foo))).

However, unique insts are not allowed to match inst parameters, so
	
	:- mode p(in(unique), out(unique)).

is not an instance of the polymorphic mode.

This syntax is currently quite convenient, but will cause problems
when we eventually allow more general polymorphic modes.  I'm
interested to see what people think about this and the `<= ground(I)'
syntax.  Does anyone have any better suggestions?

I will also post a diff of my current changes for comment.


David
-- 
David Overton       Department of Computer Science & Software Engineering
PhD Student         The University of Melbourne, Australia
+61 3 9344 9159     http://www.cs.mu.oz.au/~dmo
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list