[mercury-users] Collections of closures

David Overton dmo at cs.mu.OZ.AU
Mon Jan 10 13:48:48 AEDT 2000


On Mon, 10 Jan, 2000 at 12:57:35PM EST, Warwick Harvey wrote:
> Fergus wrote:
> > On 07-Jan-2000, Ralph Becket <rbeck at microsoft.com> wrote:
> > > :- func wrap(my_closure) = my_wrapped_closure.
> > > :- mode wrap(my_closure_in) = out is det.
> > > 
> > > :- pragma c_code(wrap(X::my_closure_in) = Y::out,
> > > 	will_not_call_mercury, "Y = X;").
> > >
> > > and vice versa for unwrapping closures.
> > 
> > For the `wrap' operation, you can use a no-op.
> 
> Really?  I don't see how.  You can't pass an object with a `pred' inst to 
> something expecting `ground', and (last time I checked) declaring the 
> `pragma c_code' to be `pred(...) -> ground' doesn't work either.  If I'm 
> missing something, please let me know!

Higher order insts are subinsts of ground and so objects with `pred'
insts can be passed anywhere a ground object is required.  The only
problem is that you lose the higher order information from the inst,
so when you want to call the object you need to ``cast'' the ground
inst back to the more specific `pred' inst, which is what your
`unwrap' operation does.


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