[GHC] #1236: System.Mem.Weak breaks referential transparency

GHC trac at galois.com
Mon Mar 19 09:09:54 EDT 2007


#1236: System.Mem.Weak breaks referential transparency
---------------------------------+------------------------------------------
    Reporter:  drtomc at gmail.com  |       Owner:         
        Type:  bug               |      Status:  new    
    Priority:  normal            |   Milestone:         
   Component:  libraries/base    |     Version:  6.6    
    Severity:  normal            |    Keywords:         
  Difficulty:  Unknown           |    Testcase:         
Architecture:  Unknown           |          Os:  Unknown
---------------------------------+------------------------------------------
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.

 cheers,
 Tom

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1236>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the Glasgow-haskell-bugs mailing list