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

Ralph Becket rafe at cs.mu.OZ.AU
Wed Aug 3 10:48:45 AEST 2005


Peter Hawkins, Wednesday,  3 August 2005:
> Hi...
> 
> 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.

Not directly that I know of, but you could do something like this (see
http://www.mercury.cs.mu.oz.au/information/doc-latest/mercury_ref/Calling-Mercury-code-from-C.html#Calling%20Mercury%20code%20from%20C)

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

:- pred invoke_closure((pred)::in((pred) is semidet)) is semidet.

invoke_closure(P) :-
	P.

and then you can write `invoke_closure(P)' directly in your C code.

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