Proposed change to ForeignPtr

George Russell ger at tzi.de
Tue Sep 10 12:33:21 EDT 2002


Simon Marlow wrote
> George: the problem with allowing callbacks from a finalizer is that in
> order to implement this your system essentially has to be able to make a
> pre-emptive context switch from the currently running Haskell
> computation to the finalizer; this turned out to have a fairly high
> implementation cost for nhc98 and Hugs, so we decided to amend the spec
> instead.  You'll still be able to do this in GHC, of course, but it
> won't be portable.

However in the case I cited it isn't particularly important to execute the callback
at once.  If calling Haskell at arbitrary times is unimplementable,
could there instead be some way of some way like "wrapper" of exporting a Haskell function
[args] -> IO () so that the resulting C function, when executed, merely registers the
Haskell action to be executed as soon as the Haskell RTS finds it convenient, rather than
at once?



More information about the FFI mailing list