[jhc] foreign import "wrapper"

Samuel Bronson naesten at gmail.com
Sun Jul 15 13:01:58 EDT 2007

On IRC, you (JohnMeacham) (what -- there is someone else who reads
this list?) said something about region inference and foreign import
"wrapper". It just occured to me earlier today that you probably can't
do much of that at all. You can basically do as much as you can do for
a StablePtr. I remind you that the C functions made by a wrapper stub
can be passed to C code and held there indefinately, just like a
StablePtr, and can only be deallocated when the Haskell program calls
freeHaskellFunPtr on them.

We also talked about how a nice way to implement these wrapper stubs,
by generating tiny thunks that would redirect calls to an evaluation
routine after adding the closure to be called as an additional
argument. (Actually, I suppose the evaluation routine would need a
wrapper, like a foreign export does...). What I'm not sure about is
how to refer to the address of the (wrapper around the) evaluation
routine in the code for the "wrapper stub" (the function that is
actually declared by the 'foreign import "wrapper"' declaration).

More information about the jhc mailing list