
I've gone through and put in a best guess for the stability/portability status, so let me know if you think any are wrong (Hugs, NHC folks: remember that every module marked "portable" is expected to be available on all implementations - so if any of these are going to cause problems, let me know).
(Without having looked at it at all) I'm half expecting to have to tweak the Foreign interface a bit since the low level grungy stuff is where compiler differences are hardest to hide.
I hope you won't have to change it, but we can discuss it on ffi@haskell.org if there's anything that will be too hard to implement in Hugs (actually, I seriously doubt it because if you can run H/Direct and green card code on Hugs, the Foreign libraries are just a different veneer over the primitives).
Does it work on NHC? (In which case changes are a lot less likely)
I remember that one of the ForeignObj-like datatypes pretty much requires threads to implement it because the finaliser is an arbitrary piece of Haskell code. This would be hard to support in Hugs and I expect NHC would have problems too.
I seem to recall NHC having some difficulty with this... Malcolm? Cheers, SImon

[ cross-posted to the FFI list ]
I remember that one of the ForeignObj-like datatypes pretty much requires threads to implement it because the finaliser is an arbitrary piece of Haskell code. This would be hard to support in Hugs and I expect NHC would have problems too.
I seem to recall NHC having some difficulty with this... Malcolm?
Yes and no. An arbitrary Haskell-code finaliser for a ForeignObj is stored in nhc98's runtime system as a StablePtr to the code. When the ForeignObj is garbage-collected, its finaliser is placed onto a 'pending' queue. Then when GC finishes, the pending queue is executed before control returns to the main evaluation. (Each item on the queue is thrown away after execution). This is all implemented, but the evaluation of the pending queue currently causes a seg fault. Chasing the bug wasn't a high priority at the time (18 months ago), and I have simply never got round to looking at it again. There is also the problem that executing a finaliser might itself cause another GC, but I can't remember if I had a solution for that. Regards, Malcolm
participants (2)
-
Malcolm Wallace
-
Simon Marlow