Proposed change to ForeignPtr

George Russell ger at tzi.de
Tue Sep 10 14:41:38 EDT 2002


Malcolm Wallace wrote
[snip]
> When sequential control returns to the Foogle world, that is when
> the Haskell GC is guaranteed to be complete.
[snip]
I don't think I recognise this notion of "sequential control".  It seems to be
assuming there is only one "real" OS thread in existence, and it is impossible
for both Foogle and Haskell to have "sequential control" over this thread at any
given moment.  When they do not have sequential control, they are not allowed to
perform garbage collection.  This model no doubt fits NHC well enough, but it seems
to be assuming an awful lot about Foogle or about the system you are running on.
To take a concrete example, suppose Haskell == NHC and Foogle = GHC, then it seems
to me the model breaks down because I imagine GHC is quite happy to do GCs and
invoke finalizers in the middle of exported functions.  Even worse, GHC at least is
now capable thanks to Sigbjorn of running in several OS threads at once (on Windows) so 
it may be doing GCs at any time whatever. 

I appreciate it's not Malcolm Wallace's fault that NHC can't implement a form of 
dynamic wrapper which can be used at all times.  However since I do not think this
problem is going to go away, would it not be better to put it in the specification but
admit that NHC can't do it?  Otherwise the FFI specification will be very good (as it is) 
if you want to call languages like C, but will be inadequate if you want to communicate 
with other languages which also know about things like concurrency and garbage-collection, 
such as Haskell or even Java.



More information about the FFI mailing list