[Haskell-cafe] Weak pointers and referential transparency???

tpledger at ihug.co.nz tpledger at ihug.co.nz
Wed Sep 13 18:59:08 EDT 2006

Brian Hulley wrote:
> tpledger at ihug.co.nz wrote:
> > My reading of the semantics
> >
> > is that you can be sure the proxy *object* is gone.
> My problem is that I don't know what to make of the word
> "object" in the  context of Haskell ie when can I be sure
> that a value is actually being  represented as a pointer
> to a block of memory and not stored in registers or
> optimized out? Or is the compiler clever enough to
> preserve the concept of  "object" despite such
> optimizations? I had been designing my Model/Proxy  data
> types with the Java notion of "everything is a pointer to
> an object"  but is this always correct relative to Haskell
> as a language or is it just a  consequence of the current
> GHC implementation?

In the context of System.Mem.Weak, but not necessarily GHC,
we're concerned solely with garbage collection of heap
objects.  So yes, that's Java-like.  AFAIK.

An example of something outside that context is a GHC Int#
(unboxed Int).  It never inhabits the heap, and isn't
allowed to be passed to a function where a polymorphic
parameter is expected (such as mkWeak).


More information about the Haskell-Cafe mailing list