Marcin 'Qrczak' Kowalczyk wrote:
> The function is described as unsafe because the result loses the
> finalizer, right? [...]

Not exactly. The real problem (pointed out to me by Manuel Chakravarty
some time ago) is exemplified by the following code snippet:

   addr <- foreignObjToAddr fo  -- last reference of `fo'
   -- Murphy's Law strikes again: GC is happening exactly here
   res <- someExternalFunction addr  -- dangling reference :-(

Passing foreign objects directly via the FFI does not have this
problem, because there is a special lifetime guarantee for this
kind of values.  :-P

Cheers,
   Sven
-- 
Sven Panne                                        Tel.: +49/89/2178-2235
LMU, Institut fuer Informatik                     FAX : +49/89/2178-2211
LFE Programmier- und Modellierungssprachen              Oettingenstr. 67
mailto:[EMAIL PROTECTED]            D-80538 Muenchen
http://www.informatik.uni-muenchen.de/~Sven.Panne

Reply via email to