[mercury-users] Higher-order calls from foreign code

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Aug 3 10:28:56 AEST 2005

On 03-Aug-2005, Peter Hawkins <peter at hawkins.emu.id.au> wrote:
> Is there a direct way to make a higher order call from foreign code? I 
> have an MR_Word which contains the address of a closure which takes no 
> arguments and is semidet, and I'd like to call it.

Write a Mercury function which does that,

	:- pred call_semidet((pred)::(pred) is semidet) is semidet.
	call_semidet(P) :- P.

and export it to C in the usual fashion. 

	:- pragma export(call_semidet((pred) is semidet), "call_semidet").

Then you can do e.g.

	MR_Word closure;


Fergus Henderson                    |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
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