
#14461: Reuse free variable lists through nested closures -------------------------------------+------------------------------------- Reporter: tdammers | Owner: alexbiehl Type: task | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: 7258 | Differential Rev(s): Wiki Page: NestedClosures | -------------------------------------+------------------------------------- Comment (by alexbiehl): I have hit a problem. Using ticket #7258 as a base line I figured that most of the closures we generate during `Read`/`Show` deriving are updatable thunks: {{{ let [fv1 fv2 ... fvn] outer = \u [] -- 'u' for updatable let [fv1 fv2 ... fvn] inner = \u [] ... }}} Applying the NestedClosure idea gets us: {{{ let [fv1 fv2 ... fvn] outer = \u [] let [outer{fv1 fv2 ... fvn}] inner = \u [] ... }}} Now, when forcing `outer` we push an update frame which overwrites `outer`s closure to be an indirection to the resulting value hereby turning the free variables effectively into garbage. We now have no safe way to access `outer`s free variables from `inner`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14461#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler