[mercury-users] Calling Mercury from C

Simon Taylor stayl at cs.mu.OZ.AU
Fri Jul 11 13:45:17 AEST 2003


On 11-Jul-2003, Michael Day <mikeday at yeslogic.com> wrote:
> 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").

That is the reliable way to call Mercury closures from C.

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

Why do you want to avoid it?

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