|  Can anyone show an example?

Sure

        xs = [1..1000] :: [Int]
        ys = [2..2000] :: [Float]

        main = do { print xs; print ys }

After printing xs, the CAF for xs is unreachable and can be GC'd.  No point in 
keeping it around.   Indeed this applies from the moment (print xs) begins 
work.  But it was
        main = do { print xs; print xs }
then the CAF for xs remains reachable until the second (print xs) starts.

Simon


PS: I am leaving Microsoft at the end of November 2021, at which point 
[email protected] will cease to work.  Use [email protected] 
instead.  (For now, it just forwards to [email protected].)

|  -----Original Message-----
|  From: ghc-devs <[email protected]> On Behalf Of Norman
|  Ramsey
|  Sent: 12 October 2021 21:55
|  To: [email protected]
|  Subject: how does a CAF become unreachable?
|  
|  I spent the afternoon spelunking through some code and the Commentary,
|  and I'm wondering how a CAF becomes unreachable.  I gather it might
|  have to do with GHC floating a static expression out of a context
|  until it becomes a CAF, but I'm still not seeing how a CAF could at
|  one point be reachable, then dynamically become unreachable.
|  
|  Can anyone show an example?
|  
|  
|  Norman
|  _______________________________________________
|  ghc-devs mailing list
|  [email protected]
|  https://nam06.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmail.
|  haskell.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fghc-
|  devs&amp;data=04%7C01%7Csimonpj%40microsoft.com%7C788a90f23049467d7636
|  08d98dc2c6ca%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637696690459
|  913210%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJ
|  BTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=8eSDcyPcNe4gSTnKJc8OQcqQI
|  %2B%2FDf9lSp3OksAV0H%2BU%3D&amp;reserved=0
_______________________________________________
ghc-devs mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

Reply via email to