[mercury-users] Calling Mercury from C

Michael Day mikeday at yeslogic.com
Fri Jul 11 13:35:49 AEST 2003


Hi,

Is there a reliable way of calling a Mercury closure from C?

At the moment, I create a Mercury forwarding predicate, export it, and 
call *that* from C, passing the closure that I wish to call.

eg.

:- pred callback(pred(...), args).
:- mode callback(pred(...), modes) is det.

callback(Pred, ...) :- Pred(...).

:- pragma export(callback(...), "callback").

Is there a way I can avoid this? I tried casting the closure directly to 
the right kind of function pointer and calling that, but it crashed.

Any tips? :)

Michael Day

-- 
YesLogic Prince prints XML!
http://yeslogic.com

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