[mercury-users] Collections of closures [polymorphic insts]

David Overton dmo at hydra.cs.mu.oz.au
Tue Jan 11 11:56:30 AEDT 2000


On Mon, 10 Jan, 2000 at 11:42:31PM EST, Ralph Becket wrote:
[...]
> Now it seems to me that we can have polymorphic insts
> in much the same was as we can have polymorphically
> typed arguments provided we accept that there are only
> a limited number of things one can do with such
> arguments.
> 
[...]
> 
> The only problemette I can think of with this scheme is
> what do you do when you copy a free variable?

One way around this would be to restrict the use of polymorphic insts
to require that, if a variable of the polymorphic inst is to be
copied, it must be ground.

To borrow some syntax from type classes, you could have a
declaration like:

:- mode nth(in(list_skel(I)), in) = out(I) is det <= ground(I).

Which will only accept ground lists as input and return ground
objects.  There is also a problem with uniqueness analysis.  The
simple solution to this would be to define that `<= ground(I)' means that
`I' is shared (i.e. not unique).

> One possibility is that you end up with an alias of that variable,

The `<= ground(I)' declaration I've just proposed removes the need to
record aliasing in the mode declaration.  Alias analysis is an area of
research I'm currently working on, which would allow more general use
of polymorphic insts that might be partially instantiated.

> but I've half convinced myself that you should really get a new free
> variable instead.

How would you do this and still keep the language declarative?


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-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