Ticket #1236 (closed bug: invalid)
System.Mem.Weak breaks referential transparency
Consider the following two functions:
foo = do
mkWeakPtr y (Just launchMissiles) return y where y = 42
bar = do
mkWeakPtr 42 (Just launchMissiles) return 42
These two functions are equivalent right? After all referential transparency means that if y = 42, then anywhere y occurrs I can write 42. The problem is that if I call foo, and hang on to the return value, then launchMissiles won't be called until some time after I stop using the return value, but if I call bar, then launchMissiles may be called any time, including before bar returns!
Looks to me like finalizers break referential transparency, so System.Mem.Weak is broken, though I'm quite willing to be proven wrong.