Re: Help me grok addFinalizer

2012-02-17 Thread Simon Marlow
On 16/02/2012 22:20, Michael Craig wrote: I haven't checked, but ... I checked, and your solution works. In the context of a larger program, getting NOLINE pragmas in all the right places would be challenging, wouldn't it? I found a bug report on the GHC Trac [1] in which Simon explains the

Help me grok addFinalizer

2012-02-16 Thread Michael Craig
When I read the docs for System.Mem.Weak, it all seems to make sense. But then this code doesn't run as I expect it to when I turn on -threaded: http://hpaste.org/63832 (Expected/actual output are listed in the paste.) I've tried this on 7.4.1 and 7.0.4 with the same results. Can someone

Re: Help me grok addFinalizer

2012-02-16 Thread Antoine Latter
On Thu, Feb 16, 2012 at 2:04 PM, Michael Craig mks...@gmail.com wrote: When I read the docs for System.Mem.Weak, it all seems to make sense. But then this code doesn't run as I expect it to when I turn on -threaded: http://hpaste.org/63832 (Expected/actual output are listed in the paste.)

Re: Help me grok addFinalizer

2012-02-16 Thread wagnerdm
Quoting Antoine Latter aslat...@gmail.com: On Thu, Feb 16, 2012 at 2:04 PM, Michael Craig mks...@gmail.com wrote: When I read the docs for System.Mem.Weak, it all seems to make sense. But then this code doesn't run as I expect it to when I turn on -threaded: http://hpaste.org/63832

Re: Help me grok addFinalizer

2012-02-16 Thread Michael Craig
This seems to be an explanation of why a finalizer might run later than expected (or not run at all). But his paste shows that it runs *earlier* than what he expected. What he said. 64-bit GHC on OS X gives me this: ... However, it's a different story when `-O2` is specified: ... You're

Re: Help me grok addFinalizer

2012-02-16 Thread Ian Lynagh
On Thu, Feb 16, 2012 at 02:55:13PM -0600, Austin Seipp wrote: 64-bit GHC on OS X gives me this: $ ghc -fforce-recomp -threaded finalizer [1 of 1] Compiling Main ( finalizer.hs, finalizer.o ) Linking finalizer ... $ ./finalizer waiting ... done! waiting ... running finalizer

Re: Help me grok addFinalizer

2012-02-16 Thread Michael Craig
I haven't checked, but ... I checked, and your solution works. In the context of a larger program, getting NOLINE pragmas in all the right places would be challenging, wouldn't it? I found a bug report on the GHC Trac [1] in which Simon explains the importance of evaluating the thunk before