Alternative Design for Finalisation

Ashley Yakeley ashley@semantic.org
Thu, 20 Sep 2001 17:58:57 -0700


At 2001-09-20 04:56, Simon Marlow wrote:

>ForeignPtrs are defined like this
>
>	data ForeignPtr a = ForeignPtr ForeignObj#
>
>where ForeignObj# is a *boxed* address, it corresponds to a real heap
>object.  The heap object is primitive from the point of view of the
>compiler - it can't be optimised away.  So it works to attach a
>finalizer to the ForeignObj# (but not to the ForeignPtr!).

OK, you are saying that the ForeignObj# is a representation of a 'Ptr a', 
but in a way such that the compiler can't optimise away the box. Is that 
correct?

Could ForeignPtr be generalised so that its ForeignObj# could represent 
any type, rather than just a Ptr?

-- 
Ashley Yakeley, Seattle WA