Dear GHC users,

can someone please give me any hints that help me to understand
where the versions of the funktion "createOMSObjectDesignator" differ,
so that the one does what I intend and the other version does
not !?

Would this also work without using the MVar ?

I did use GHC 2.01.

Thanks, Stefan.
--
Stefan Westmeier                              [EMAIL PROTECTED]
Schaphuser Str. 24                                                    
D-28307 Bremen                             vox humana: +(49) 421 424001
Germany                                   fax machina: +(49) 421 424045

=======================================================================

data PcteObjectReference    = PcteObjectReference Addr 
                            | PcteNullObjectReference

data OMSObjectDesignator = 
        NullOMSObjectDesignator
      | MkOMSObjectDesignator (MVar DST)

data DST =
        DST
                PcteObjectReference
                ForeignObj


getORef :: OMSObjectDesignator -> IO PcteObjectReference
getORef (MkOMSObjectDesignator dst) = do {
        (DST oref _ ) <- readMVar dst;
        return oref
}


createOMSObjectDesignator :: PcteObjectReference -> IO OMSObjectDesignator

-- hier wird dann auch das Desctructable Object erzeugt
createOMSObjectDesignator oref@(PcteObjectReference a) = do {
        -- this gets the address of my finalization function
        finAddr <- primIOToIO (_ccall_ AddrFreeObjectReference);

{-      -- this does not work, because the finalization 
        -- function is called more than once for the address
        fobj <- primIOToIO (makeForeignObj a finAddr);
        mv <- newMVar (DST oref fobj);
-}
        -- this does work --- why
        mv <- newMVar (DST oref (unsafePerformPrimIO(makeForeignObj a finAddr)));


        return (MkOMSObjectDesignator mv)
}

Reply via email to