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

tpledger at ihug.co.nz tpledger at ihug.co.nz
Tue Sep 12 06:31:42 EDT 2006

Brian Hulley wrote:
>         Ref.write proxiesRef $! (weakProxy : proxies)

(This is nothing to do with your main question, but the
strict application looks unnecessary there.  Its right hand
side is already a constructor cell.)

> In other words, if the entry for the proxy
> in the table stored in the Model dies, can
> I be absolutely 100% sure that this means
> the proxy no longer exists in any shape or
> form in the running program?

My reading of the semantics
is that you can be sure the proxy *object* is gone.

As for referential transparency...

If you create equivalent proxies in different calls to
createProxy, it's possible that they'll end up referring to
the same object (e.g. if the compiler or RTS does something
fancy, or you use a memoised smart constructor).  So then a
single live proxy object *could* protect many elements of
your Weak Proxy list from scavenging.

It would seem perverse to cry "referential transparency!"
and spontaneously clone one of your proxy objects.  That
*could* lead to deRefWeak returning Nothing while an
*equivalent* Proxy object is still alive.  Might you run
your program on an avant-garde distributed RTS?  ;-)


More information about the Haskell-Cafe mailing list